Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user's download folder in Qt?

Tags:

qt

How do I get the standard system / user paths in Qt?

What I really need is to get the location of the user's Downloads folder.

like image 771
Nathan Osman Avatar asked Aug 26 '10 04:08

Nathan Osman


2 Answers

In Qt 4, there is QDesktopServices providing some user paths:

https://doc.qt.io/qt-4.8/qdesktopservices.html#StandardLocation-enum

It has e.g. Desktop and Documents but no specific Downloads folder.

In Qt 5, use QStandardPaths:

const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
like image 192
Frank Osterfeld Avatar answered Oct 14 '22 11:10

Frank Osterfeld


You can use QDir::homePath() to get a QString to the home directory of the current user's profile but I'm not sure that there is a "standard" download directory identified by the OS.

like image 30
Arnold Spence Avatar answered Oct 14 '22 10:10

Arnold Spence