//返回包含应用程序可执行文件的目录
QString AppPath=QCoreApplication::applicationDirPath();
qDebug()<<AppPath;
//返回应用程序当前目录的绝对路径
QString CurPath=QDir::currentPath();
qDebug()<<CurPath;
//文件名
QString FileName = "\\test.txt";
QString Path = QCoreApplication::applicationDirPath() + FileName;
//用\\代替/
Path.replace("/","\\");
//可以用QFile打开
qDebug()<<Path;
运行结果如下: