[Development] Differences: QDesktopServices vs QStandardPaths

David Faure faure at kde.org
Wed Jul 10 10:57:39 CEST 2013

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 
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.

Please confirm that this solution works for you, and I'll add porting 
documentation to QDesktopServices about this solution.

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.

David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5

More information about the Development mailing list