Qt获取系统相关位置
来源:互联网 发布:谷歌域名 编辑:程序博客网 时间:2024/06/07 01:55
在使用比如打开文件对话框(QFileDialog)时,想让其打开位置位于用户桌面等位置
Qt为我们提供了函数,使其实现起来十分方便
Qt4--Qt5用QDesktopServices;
首先要引入头文件
#include <QDesktopServices>然后可以通过如下语句获取不同的路径
static QString QDesktopServices::storageLocation(StandardLocation type);例如:获取桌面路径
//获取桌面路径 QString path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
=====================================================================================================================
Qt5以后用QStandardPaths;
首先要引用头文件
#include <QStandardPaths>
然后可以通过如下语句获取不同的路径
static QString writableLocation(StandardLocation type);也可以通过一下语句获取路径下的文件和文件夹(注意:该函数返回值类型是list)
static QStringList standardLocations(StandardLocation type);
例如:获取桌面路径
QString path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
参数为路径名字的指代值,列表如下QStandardPaths::DesktopLocation0Returns the user's desktop directory.QStandardPaths::DocumentsLocation1Returns the user's document.QStandardPaths::FontsLocation2Returns the user's fonts.QStandardPaths::ApplicationsLocation3Returns the user's applications.QStandardPaths::MusicLocation4Returns the user's music.QStandardPaths::MoviesLocation5Returns the user's movies.QStandardPaths::PicturesLocation6Returns the user's pictures.QStandardPaths::TempLocation7Returns the system's temporary directory.QStandardPaths::HomeLocation8Returns the user's home directory.QStandardPaths::DataLocation9Returns 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::CacheLocation10Returns a directory location where user-specific non-essential (cached) data should be written.QStandardPaths::GenericCacheLocation15Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written.QStandardPaths::GenericDataLocation11Returns a directory location where persistent data shared across applications can be stored.QStandardPaths::RuntimeLocation12Returns a directory location where runtime communication files should be written. For instance unix local sockets.QStandardPaths::ConfigLocation13Returns a directory location where user-specific configuration files should be written.QStandardPaths::DownloadLocation14Returns a directory for user's downloaded files.
0 0
- Qt获取系统相关位置
- Qt获取系统相关位置
- Qt获取系统相关位置
- Qt获取系统相关位置路径
- QT位置相关函数
- qt获取光标位置
- C++/QT 获取系统CPU、内存、磁盘、进程相关信息
- qt 中获取鼠标位置
- Qt获取鼠标位置(绝对位置、相对位置)
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- QT获取系统时间
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- QT 获取系统屏幕分辨率
- php Logs类
- java.lang.NoClassDefFoundError:org/apache/commons/lang/exception/NestableRuntimeException报错的原因
- 队列(数组模拟)
- 将带有、号的字符串,以逗号分割,然后拼接为SQL语句的WHERE条件
- React +ES6 +Webpack入门
- Qt获取系统相关位置
- Linux mysql mariadb
- 互联网:制造业转型升级的助推器
- ListView在ScrollView中显示
- 图像去模糊从环境 配置到算法效果
- loadrunner 当有用户登录失败时,重新执行登录脚本
- Faster RCNN算法详解
- php安装redis扩展
- URL字段截取