如何查找Qt应用程序的安装目录
How to find the installation directory of a Qt application?
我有一个基于Qt的应用程序,适用于Mac和Windows。 当用户安装软件时,它还会安装一个包含一堆HTML文档页面的文件夹。我如何找到程序安装的位置,以便当用户尝试从应用程序中打开帮助时,他们会被带到index.html
.
我的程序安装在 Windows 和 Mac 的正常位置。 在Mac上,我的程序安装到/Users/username/Applications/MyProgram
其中MyProgram
是一个包含"MyProgram.app"和"Doc"文件夹的文件夹。
#ifdef Q_OS_MACX
docPath = executablePath + "/Doc/index.html";
#elif Q_OS_WIN
docPath = executablePath + "/Doc/index.html";
#endif
QDesktopServices::openUrl(QUrl::fromLocalFile(docPath));
所以,我的终极问题是,executablePath
应该是什么? 此外,这假设用户可以将程序安装在默认位置以外的其他位置,或者可以从快捷方式启动程序。
你应该使用:
QString QCoreApplication::applicationDirPath() [static]
相关文章:
- 通过安装信号处理程序关闭多线程应用程序
- Qt在安装Visual Studio 2019和虚幻引擎后无法运行示例应用程序
- 如何检查应用程序是否安装了 jni?
- 错误:尝试在全新系统安装中构建应用程序后未定义对'...'的引用
- 应用程序仅在安装了 Visual Studio 的 PC 上启动.这种行为的原因可能是什么
- 在 Ubuntu 16.04 的 usr/local/bin 中安装的 c++ 应用程序在从主目录执行时无法正常运行
- 即使我已经安装了 poco,应用程序也无法检测到C++ poco
- 如何使用PJSIP库在MINGW上安装NASM,以构建Windows应用程序的OpenH264库
- 如果应用程序从安装选项启动,则加载库失败,错误代码为 126
- 如何正确安装开源UEYE应用程序的缺失LIB
- 必须在客户端计算机上安装的内容才能运行QT快速应用程序
- 全球安装的键盘钩可防止键盘输入其他应用程序
- 使用Visual Studio 2015社区版为应用程序制作安装程序,其中集成了VC++ 2015环境
- POPEN 可以找出是否安装了某些应用程序吗?
- 如何使用已安装的火狐或 chrome 在应用程序中C++渲染 html
- 我尝试运行我在 eclipse 中创建的 c++ 应用程序(它的.exe),它说"libgcc_s_dw2-1.dll丢失并尝试重新安装
- 如何为 Mac OS X 安装命令行应用程序
- 从C++应用程序创建Mac OS X的安装程序
- 如何在没有[DefaultInstall]部分的情况下从.NET桌面应用程序安装INF驱动程序
- 如何为USSD应用程序安装LeibICT ?