Obsolete Members for QDesktopServices

The following members of class QDesktopServices are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

Public Types

(obsolete) enum StandardLocation { DesktopLocation, DocumentsLocation, FontsLocation, ApplicationsLocation, ..., CacheLocation }

Static Public Members

(obsolete) QString displayName(StandardLocation type)
(obsolete) QString storageLocation(StandardLocation type)

Member Type Documentation

enum QDesktopServices::​StandardLocation

Use QStandardPaths::StandardLocation (see storageLocation() for porting notes)

This enum describes the different locations that can be queried by QDesktopServices::storageLocation and QDesktopServices::displayName.

ConstantValueDescription
QDesktopServices::DesktopLocation0Returns the user's desktop directory.
QDesktopServices::DocumentsLocation1Returns the user's document.
QDesktopServices::FontsLocation2Returns the user's fonts.
QDesktopServices::ApplicationsLocation3Returns the user's applications.
QDesktopServices::MusicLocation4Returns the users music.
QDesktopServices::MoviesLocation5Returns the user's movies.
QDesktopServices::PicturesLocation6Returns the user's pictures.
QDesktopServices::TempLocation7Returns the system's temporary directory.
QDesktopServices::HomeLocation8Returns the user's home directory.
QDesktopServices::DataLocation9Returns a directory location where persistent application data can be stored. QCoreApplication::applicationName and QCoreApplication::organizationName should work on all platforms.
QDesktopServices::CacheLocation10Returns a directory location where user-specific non-essential (cached) data should be written.

This enum was introduced or modified in Qt 4.4.

See also storageLocation() and displayName().

Member Function Documentation

[static] QString QDesktopServices::​displayName(StandardLocation type)

Use QStandardPaths::displayName()

[static] QString QDesktopServices::​storageLocation(StandardLocation type)

Use QStandardPaths::writableLocation()

Note: when porting QDesktopServices::DataLocation to QStandardPaths::DataLocation, a different path will be returned.

QDesktopServices::DataLocation was GenericDataLocation + "/data/organization/application", while QStandardPaths::DataLocation is GenericDataLocation + "/organization/application".

Also note that application could be empty in Qt 4, if QCoreApplication::setApplicationName() wasn't called, while in Qt 5 it defaults to the name of the executable.

Therefore, if you still need to access the Qt 4 path (for example for data migration to Qt 5), replace

QDesktopServices::storageLocation(QDesktopServices::DataLocation)

with

QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) +
"/data/organization/application"

(assuming an organization name and an application name were set).

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.