[Development] Differences: QDesktopServices vs QStandardPaths

Chris W chrisw.qtdevel at psychogeeks.com
Thu Jul 11 00:06:05 CEST 2013

On 10/07/13 18:57, David Faure wrote:
> Le mercredi 10 juillet 2013 09:41:59 Mark a écrit :
>>> QString paths =
>>> QDesktopServices::storageLocation(QDesktopServices::DataLocation);
> After reading the forum post, I have a more complete answer; posting here for
> posterity.
> If your Qt4 code does the above, in Qt5 you can either:
> * move the data once and for all (from data/org/app to org/app)
> * keep using the deprecated QDesktopServices::DataLocation
> * port to this instead:
> QStandardPaths::writableLocation(GenericDataLocation) + “data/org/app”.
> The latter is the future-proof way of accessing that (old) data/org/app
> directory under local/share, for people who don't want to move it.
This is more-or-less what to allow my Qt5 version to move the 
pre-existing Qt4 folder to the new location.
> Please confirm that this solution works for you, and I'll add porting
> documentation to QDesktopServices about this solution.
This is good.  A note in the docs regarding the extra "data" folder and 
alternatives for getting at it would be excellent.
> I withdraw my suggestion of a Qt4DataLocation because this is basically what
> QDesktopServices::DataLocation is. IOW, the compat code already exists, it's
> exactly there in QDesktopServices -- and there is another difference than the
> "data" subdir, it's what happens when the applicationName isn't set, in Qt4 it
> was empty, in Qt5 it comes from the executable name.
I agree, this was messy and, as you say, the deprecated code is still 
available (for those who can work out how to un-hide it).

Thanks for your time.


More information about the Development mailing list