在Qt中,可以使用QCoreApplication::applicationDirPath()函数来获取应用程序的当前目录。

示例代码如下:

#include <QCoreApplication>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString currentDir = QCoreApplication::applicationDirPath();
    qDebug() << "Current directory: " << currentDir;

    return a.exec();
}

上述代码中,QCoreApplication::applicationDirPath()函数返回一个QString类型的值,表示应用程序的当前目录。通过调用qDebug()函数将当前目录输出到控制台。

Qt如何获取应用程序的当前目录

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

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