QT 路径打印
打印路径
void PrintPath() { qDebug() << u8"可执行文件所在目录:" << QCoreApplication::applicationDirPath(); qDebug() << u8"可执行文件绝对路径:" << QCoreApplication::applicationFilePath(); qDebug() << u8"可执行文件名:" << QCoreApplication::applicationName(); qDebug() << u8"当前程序运行目录:" << QDir::currentPath(); }
输出:
[DEBUG][Qt] 27.07.2022 21:42:22 [] (unknown:0) - 可执行文件所在目录: "F:/Slicer/Slicer-build/bin/RelWithDebInfo" [DEBUG][Qt] 27.07.2022 21:42:22 [] (unknown:0) - 可执行文件绝对路径: "F:/Slicer/Slicer-build/bin/RelWithDebInfo/SlicerApp-real.exe" [DEBUG][Qt] 27.07.2022 21:42:22 [] (unknown:0) - 可执行文件名: "Slicer" [DEBUG][Qt] 27.07.2022 21:42:22 [] (unknown:0) - 当前程序运行目录: "D:/documents/slicer/SegForDetect/build"