Obsolete Members for QDesktopServices

以下成員源於類 QDesktopServices 已過時。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。

公共類型

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

靜態公共成員

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

成員類型文檔編製

enum QDesktopServices:: StandardLocation

使用 QStandardPaths::StandardLocation (見 storageLocation () for porting notes)

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

常量 描述
QDesktopServices::DesktopLocation 0 Returns the user's desktop directory.
QDesktopServices::DocumentsLocation 1 Returns the user's document.
QDesktopServices::FontsLocation 2 Returns the user's fonts.
QDesktopServices::ApplicationsLocation 3 Returns the user's applications.
QDesktopServices::MusicLocation 4 Returns the users music.
QDesktopServices::MoviesLocation 5 Returns the user's movies.
QDesktopServices::PicturesLocation 6 Returns the user's pictures.
QDesktopServices::TempLocation 7 Returns the system's temporary directory.
QDesktopServices::HomeLocation 8 Returns the user's home directory.
QDesktopServices::DataLocation 9 Returns a directory location where persistent application data can be stored. QCoreApplication::applicationName and QCoreApplication::organizationName should work on all platforms.
QDesktopServices::CacheLocation 10 Returns a directory location where user-specific non-essential (cached) data should be written.

該枚舉在 Qt 4.4 引入或被修改。

另請參閱 storageLocation () 和 displayName ().

成員函數文檔編製

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

使用 QStandardPaths::displayName ()

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

使用 QStandardPaths::writableLocation ()

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

QDesktopServices::DataLocation was GenericDataLocation + "/data/organization/application" ,而 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).