1. static bool openUrl(const QUrl &url);
The openUrl() function is used to open files located at arbitrary URLs in external applications. For URLs that correspond to resources on the local filing system (where the URL scheme is “file”), a suitable application will be used to open the file; otherwise, a web browser will be used to fetch and display the file.
采用openUrl()函数,可以根据Url的类型,选择一个合适的应用程序(一般是采用默认应用程序)打开该url指向的文件;
static bool openUrl(const QUrl &url);
//QString fileName(qApp->applicationDirPath() + QStringLiteral("要打开的文件"));
QString fileName(“要打开的文件路径”);
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(fileName).absoluteFilePath())))
{
QMessageBox::information(this, tr("warning"),
tr("Failed to open the help guide."),
QMessageBox::Ok);
}