在 Qt 中,可以使用 'QCoreApplication::applicationFilePath()' 函数来获取当前可执行文件的路径。

示例代码如下:

#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    
    QString exePath = QCoreApplication::applicationFilePath();
    qDebug() << "Executable path:" << exePath;
    
    return a.exec();
}

运行该程序,将会输出当前可执行文件的路径。


原文地址: https://www.cveoy.top/t/topic/pxYC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录