How to get user's download folder in Qt?

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);

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.

Tags:

Qt