Qt5获取系统目录

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

所需头文件:

#include <QDesktopServices>

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

QString QStandardPaths::writableLocation(StandardLocation type)

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

QStringList QStandardPaths::standardLocations(StandardLocation type)

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

Qt 的详细介绍请点这里
Qt 的下载地址请点这里

猜你喜欢

转载自www.linuxidc.com/Linux/2015-09/123101.htm
Qt5