文件
标准路径
Qt 提供了 QStandardPaths 用来查询系统中各种标准路径。枚举 QStandardPaths::StandardLocation 定义了系统的各种标准路径。要查询标准路径的字符串形式,需要以下两个函数之一:
// 返回标准路径的列表
QStringList standardLocations(QStandardPaths::StandardLocation type);
// 返回可写的标准路径
QString writableLocation(QStandardPaths::StandardLocation type);
一个典型的查询路径方式为:
QString defaultPath = "/tmp/pictures";
auto paths = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
if(!paths.isEmpty()) {
defaultPath = paths;
}