唯客微博客

专注于计算机,嵌入式领域的技术

0%

QT获取下载、桌面、临时文件....等系统默认目录

QT获取下载、桌面、临时文件....等系统默认目录

头文件:

1
#include <QStandardPaths>

示例代码:

1
2
3
4
5
6
7
8
9
qDebug()<<"系统字体目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::FontsLocation);
qDebug()<<"系统桌面目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
qDebug()<<"用户文档目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
qDebug()<<"用户音乐目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::MusicLocation);
qDebug()<<"用户图片目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
qDebug()<<"系统临时文件目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::TempLocation);
qDebug()<<"系统缓存目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::CacheLocation);
qDebug()<<"系统下载目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::DownloadLocation);
qDebug()<<"系统缓存目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::CacheLocation);

每个枚举的功能参见手册

-------------本文结束感谢您的阅读-------------

本文标题:QT获取下载、桌面、临时文件....等系统默认目录

文章作者:Vinx

发布时间:2023年05月19日 - 11:50

最后更新:2023年09月19日 - 08:49

原始链接:https://blog.vinkvin.com/post/87/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。