路径获取方法:
// 获取应用程序当前工作目录的绝对路径
QString currentPath=QDir::currentPath()+ "/1.txt";
qDebug()<<currentPath;
qDebug()<<QDir::currentPath()+"/school_picture.png";
// 获取应用程序可执行文件所在的目录
QCoreApplication::applicationDirPath();
QString applicationDirPath;
applicationDirPath = QCoreApplication::applicationDirPath();
qDebug()<<applicationDirPath;
// 获取应用程序可执行文件的文件路径
QCoreApplication::applicationFilePath();
QString applicationFilePath;
applicationFilePath = QCoreApplication::applicationFilePath();
qDebug()<<applicationFilePath;
文件中的绝对路径:
拼接的方式
如QFile file (QDir::currentPath()+"/vertex1.txt");
标签:QT,currentPath,路径,applicationDirPath,获取,QCoreApplication,applicationFilePath,qDe From: https://www.cnblogs.com/jrehua/p/17215816.html