1.程序所在路径:
// 当前程序所在路径+exe
qDebug()<<qApp->applicationDirPath();
//当前程序所在路径
qDebug()<<qApp->applicationFilePath();
2.当前工作路径:
QString QDir::currentPath()
3.用户目录路径:
qDebug()<<QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
//output:"C:/Users/Administrator"
QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
//output:("C:/Users/Administrator")
4.我的文档路径:
qDebug()<<"writableDocuments"<<QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
//output:"C:/Users/Administrator/Documents"
qDebug()<<"standDocuments"<<QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
//output:("C:/Users/Administrator/Documents")
5.桌面路径
QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
6.程序数据存放路径
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
//output:"C:/Users/Administrator/AppData/Roaming/AppName"
QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation);
//output:"C:/Users/Administrator/AppData/Roaming/AppName"
7.临时文件路径
QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QStandardPaths::standardLocations(QStandardPaths::TempLocation);
QDir::tempPath()