Qt5获取系统目录

2015-11-10 13:45:59 · 作者: · 浏览: 6

Qt4使用 QDesktopServices::storageLocation(QDesktopServices::xxxx) 来获取一些系统目录,Qt5则要改成 QStandardPaths::writableLocation(QStandardPaths::xxxx)。


所需头文件:


#include


然后可以通过如下语句获取不同的路径:


QString QStandardPaths::writableLocation(StandardLocation type)


也可以通过一下语句获取路径下的文件和文件夹:


QStringList QStandardPaths::standardLocations(StandardLocation type)


参数为路径名字的指代值,列表如下: