Narek
Narek

Reputation: 39881

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

For each OS there is a location for storing temporary data. It could be like: C:/Users/[user name]/AppData/Temp (or so). How can I get this path independently from OS with QT?

Upvotes: 12

Views: 17641

Answers (3)

mtvec
mtvec

Reputation: 18326

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().

Upvotes: 26

ForgottenUmbrella
ForgottenUmbrella

Reputation: 1120

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.

Upvotes: 2

MSalters
MSalters

Reputation: 180010

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

Upvotes: 4

Related Questions