Linux 拨号vps windows公众号手机端

qt获取当前路径的方法是什么

lewis 8年前 (2017-10-08) 阅读数 15 #程序编程
文章标签 qt

要获取当前路径,可以使用QCoreApplication::applicationDirPath()方法。该方法返回一个QString,表示应用程序的当前路径。下面是一个示例代码:

#include <QCoreApplication>
#include <QDebug>

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

运行上述代码,会打印出当前路径。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门