Qt5获取系统目录

来源:互联网 发布:连江有淘宝培训班吗 编辑:程序博客网 时间:2024/05/16 03:03

Qt4使用 QDesktopServices::storageLocation(QDesktopServices::xxxx) 来获取一些系统目录,

Qt5则要改成QStandardPaths::writableLocation(QStandardPaths::xxxx)


所需头文件:

[cpp] view plain copy
  1. #include <QDesktopServices>  

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

[cpp] view plain copy
  1. QString QStandardPaths::writableLocation(StandardLocation type)  

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

[cpp] view plain copy
  1. QStringList QStandardPaths::standardLocations(StandardLocation type)  

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




参考资料:http://blog.csdn.net/vinson0526

原创粉丝点击