How to find the installation directory of a Qt application?
我有一个基于Qt的应用程序,适用于Mac和Windows。 当用户安装软件时,它还会安装一个包含一堆HTML文档页面的文件夹。 我如何找到程序的安装位置,以便当用户尝试从应用程序中打开"帮助"时,将其带到
我的程序安装在Windows和Mac的常规位置。 在Mac上,我的程序安装到
1 2 3 4 5 6 7 | #ifdef Q_OS_MACX docPath = executablePath +"/Doc/index.html"; #elif Q_OS_WIN docPath = executablePath +"/Doc/index.html"; #endif QDesktopServices::openUrl(QUrl::fromLocalFile(docPath)); |
因此,我的最终问题是
您应该使用:
1 | QString QCoreApplication::applicationDirPath() [static] |