Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 540
Narek Avatar asked Jun 22 '10 07:06

Narek


People also ask

Where is temp file path?

Temp files often have the extension . TMP and are stored in the C:\Users\AppData\Local\Temp folder.

Where can users save temporary files in Linux?

In Unix and Linux, the global temporary directories are /tmp and /var/tmp. Web browsers periodically write data to the tmp directory during page views and downloads. Typically, /var/tmp is for persistent files (as it may be preserved over reboots), and /tmp is for more temporary files.

How do I make AC temp folder?

Open your File Explorer (it's usually the first button on your desktop taskbar, looks like a folder). Go to the "This PC" section on the left, and then double-click your C: drive. On the Home tab at the top, click "New Folder" and name it "Temp".


2 Answers

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

like image 85
mtvec Avatar answered Sep 28 '22 23:09

mtvec


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

like image 45
MSalters Avatar answered Sep 28 '22 22:09

MSalters