Tuesday, February 11, 2014

Qt 5: QStandardPaths::DownloadLocation returns Documents folder starting from Vista

In Qt 5 the QStandardPaths provides access to the (guess what?) system standard paths like user's documents path, fonts path, etc.

There is also a Downloads path (QStandardPaths::DownloadLocation) that should return the directory where downloaded files are stored. Starting with Windows Vista there is a special directory for downloads. Before that the Documents directory was used.

However the Qt implementation of QStandardPaths does not make use of this new directory and always returns the Documents (QStandardPaths::DocumentsLocation) when the Downloads location is requested.

This patch fixes this issue, now QStandardPaths::DownloadLocation will correctly return the Downloads directory for Vista (or greater).

The patch has to be applied to file qtbase\src\corelib\io\qstandardpaths_win.cpp
And it is good for both Qt 5.2 and 5.2.1