开发者

Qt - How to get the "Temp" dir for an arbitrary user?

开发者 https://www.devze.com 2023-01-04 12:46 出处:网络
For each OS there is a location for storing temporary data. It could be like: C:/Users/[user name]/AppData/Temp (or so). How ca开发者_高级运维n I get this path independently from OS with QT?It is not

For each OS there is a location for storing temporary data. It could be like: C:/Users/[user name]/AppData/Temp (or so). How ca开发者_高级运维n I get this path independently from OS with QT?


It is not possible to get the temp directory for an arbitrary user, but for the current user you can use QDir::temp() or QDir::tempPath().


You want to get QDesktopServices::TempLocation. See http://doc.trolltech.com/qtextended4.4/qdesktopservices.html#StandardLocation-enum for details.


In Qt 5, you can use QStandardPaths::writableLocation(QStandardPaths::TempLocation) to get the temporary directory path as a QString. You'll need to #include <QStandardPaths> to do so.

0

精彩评论

暂无评论...
验证码 换一张
取 消