Qt获取系统相关位置
2013-09-26 15:28
309 查看
在使用比如打开文件对话框(QFileDialog)时,想让其打开位置位于用户桌面等位置
Qt为我们提供了函数,使其实现起来十分方便
首先要引用头文件
[cpp] view
plaincopy
#include <QDesktopServices>
然后可以通过如下语句获取不同的路径
[cpp] view
plaincopy
QString QStandardPaths::writableLocation(StandardLocation type)
也可以通过一下语句获取路径下的文件和文件夹
[cpp] view
plaincopy
QStringList QStandardPaths::standardLocations(StandardLocation type)
参数为路径名字的指代值,列表如下
转自:/content/8240534.html
Qt为我们提供了函数,使其实现起来十分方便
首先要引用头文件
[cpp] view
plaincopy
#include <QDesktopServices>
然后可以通过如下语句获取不同的路径
[cpp] view
plaincopy
QString QStandardPaths::writableLocation(StandardLocation type)
也可以通过一下语句获取路径下的文件和文件夹
[cpp] view
plaincopy
QStringList QStandardPaths::standardLocations(StandardLocation type)
参数为路径名字的指代值,列表如下
QStandardPaths::DesktopLocation | 0 | Returns the user's desktop directory. |
QStandardPaths::DocumentsLocation | 1 | Returns the user's document. |
QStandardPaths::FontsLocation | 2 | Returns the user's fonts. |
QStandardPaths::ApplicationsLocation | 3 | Returns the user's applications. |
QStandardPaths::MusicLocation | 4 | Returns the user's music. |
QStandardPaths::MoviesLocation | 5 | Returns the user's movies. |
QStandardPaths::PicturesLocation | 6 | Returns the user's pictures. |
QStandardPaths::TempLocation | 7 | Returns the system's temporary directory. |
QStandardPaths::HomeLocation | 8 | Returns the user's home directory. |
QStandardPaths::DataLocation | 9 | Returns a directory location where persistent application data can be stored. QCoreApplication::organizationName and QCoreApplication::applicationName are appended to the directory location returned for GenericDataLocation. |
QStandardPaths::CacheLocation | 10 | Returns a directory location where user-specific non-essential (cached) data should be written. |
QStandardPaths::GenericCacheLocation | 15 | Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written. |
QStandardPaths::GenericDataLocation | 11 | Returns a directory location where persistent data shared across applications can be stored. |
QStandardPaths::RuntimeLocation | 12 | Returns a directory location where runtime communication files should be written. For instance unix local sockets. |
QStandardPaths::ConfigLocation | 13 | Returns a directory location where user-specific configuration files should be written. |
QStandardPaths::DownloadLocation | 14 | Returns a directory for user's downloaded files. |
相关文章推荐
- Qt获取系统相关位置
- Qt获取系统相关位置
- QSettings操作配置文件及Qt获取系统相关位置
- Qt获取系统相关位置路径
- C++/QT 获取系统CPU、内存、磁盘、进程相关信息
- QT位置相关函数
- Linux系统内存相关信息获取
- Java获取系统信息(cpu,内存,硬盘,进程等)的相关方法
- Android获取系统相关的信息
- QT简单获取当期系统时间
- 获取jdk所在系统相关属性
- selenium相关:通过location 和 size 获取元素所在像素位置和尺寸,截取图片ROI
- Qt获取本机的IP地址、用户名等相关信息
- 如何获取系统任务栏位置
- QT中QString 类的使用--获取指定字符位置、截取子字符串等
- QT中鼠标位置获取问题之event->globalPos()与pos()函数
- android获取系统相关信息(后续更新)
- android获取系统相关
- QT 获取系统屏幕分辨率
- C# 获取计算机系统相关信息