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


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

头文件:

#include <QStandardPaths>

示例代码:

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);

每个枚举的功能参见手册


文章作者: Vinx
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Vinx !
 上一篇
Jetpack Compose 使用技巧 - HorizontalPager Jetpack Compose 使用技巧 - HorizontalPager
Jetpack Compose 使用技巧 - HorizontalPager 1. HorizontalPager 页面变化回调 fun PhotoPagerScreen( images: List<Image>,
下一篇 
平面三角形外接(内切)圆圆心与半径求解算法 平面三角形外接(内切)圆圆心与半径求解算法
平面三角形外接(内切)圆圆心与半径求解算法 0.1 三角形面积S与外接圆半径R的关系 \[ \begin{align*} S &= \frac{a * b * c}{4 * R} \\ 外接圆半径R &= \fr
2023-05-10
  目录