PDA

View Full Version : QStandardPaths returning incorrent folder



Momergil
19th February 2014, 19:23
Hello!

I'm learning about the usage of the new Qt 5 class QStandardPaths by reading Qt Assistant, etc.. For curiosity, I decided to get the list of my computer's folders when I call QStandardPaths::standardLocations(StandartLocation ) to see what I got when, for my surprise, after asking for retrieving my downloads folder,



qDebug() << QStandardPaths::standardLocations(QStandardPaths:: DownloadLocation);


I received my documents folder ("C:/Users/Endrigo/Documents") instead of my actual downloads folder ("C:/Users/Endrigo/Downloads"). Isn't this a bug in this class? I called the functions multiple times and neither once the correct folder path was given (not forgetting that the result of standartLocations is a QStringList, so no problem if there were other options apart from it insofar "C:/Users/Endrigo/Downloads" was given).



Thanks,

Momergil

ChrisW67
20th February 2014, 00:09
That will depend on what version of the ever moving target called Windows you are running. Before Vista no such location existed in the Windows special folders. Vista introduced a different function (SHGetKnownFolderPath(FOLDERID_Downloads) (http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188%28v=vs.85%29.aspx)) reporting a different range of paths, including FOLDERID_Downloads. The Qt code uses the old method and returns the documents folder as a place you can download to that is available on Windows XP also.

There is a outstanding bug in work and code that you might adapt to find the location in the meantime.
https://bugreports.qt-project.org/browse/QTBUG-35194

Momergil
20th February 2014, 14:38
There is a outstanding bug in work and code that you might adapt to find the location in the meantime.

Thanks for the answer, Chris. Thankfully I'm not actually in need for a correct implementation of that method, so I'll wait for further Qt releases.


Momergil