Reputation: 73275
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.
Upvotes: 17
Views: 19206
Reputation: 31
With Qt 5.15.0, on a fr-FR Linux (Manjaro) :
qDebug() << QStandardPaths::displayName(QStandardPaths::DownloadLocation);
returns :
"Téléchargement"
This is not the actual French "DownloadLocation" folder name, which is called "Téléchargements", with a plural s, because this folder usually contains more than one downloaded file. Btw, English localization seems to be "~/Downloads", according to Qt 5 online help, with the expected plural s.
Therefore, QStandardPaths::DownloadLocation is unreliable in French. If someone may file and follow the bug at Qt, this might help !
Upvotes: 1
Reputation: 25165
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);
Upvotes: 39
Reputation: 22282
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.
Upvotes: 17