![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qstandardpaths.h>
Public Types | |
enum | StandardLocation { DesktopLocation , DocumentsLocation , FontsLocation , ApplicationsLocation , MusicLocation , MoviesLocation , PicturesLocation , TempLocation , HomeLocation , AppLocalDataLocation , CacheLocation , GenericDataLocation , RuntimeLocation , ConfigLocation , DownloadLocation , GenericCacheLocation , GenericConfigLocation , AppDataLocation , AppConfigLocation , PublicShareLocation , TemplatesLocation , StateLocation , GenericStateLocation } |
This enum describes the different locations that can be queried using methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, and QStandardPaths::displayName. More... | |
enum | LocateOption { LocateFile = 0x0 , LocateDirectory = 0x1 } |
This enum describes the different flags that can be used for controlling the behavior of QStandardPaths::locate and QStandardPaths::locateAll. More... | |
Static Public Member Functions | |
static QString | writableLocation (StandardLocation type) |
static QStringList | standardLocations (StandardLocation type) |
static QString | locate (StandardLocation type, const QString &fileName, LocateOptions options=LocateFile) |
static QStringList | locateAll (StandardLocation type, const QString &fileName, LocateOptions options=LocateFile) |
[0] | |
static QString | displayName (StandardLocation type) |
static QString | findExecutable (const QString &executableName, const QStringList &paths=QStringList()) |
static void | setTestModeEnabled (bool testMode) |
static bool | isTestModeEnabled () |
\inmodule QtCore
The QStandardPaths class provides methods for accessing standard paths.
This class contains functions to query standard locations on the local filesystem, for common tasks such as user-specific directories or system-wide configuration directories.
Definition at line 15 of file qstandardpaths.h.
This enum describes the different flags that can be used for controlling the behavior of QStandardPaths::locate and QStandardPaths::locateAll.
\value LocateFile return only files \value LocateDirectory return only directories
Enumerator | |
---|---|
LocateFile | |
LocateDirectory |
Definition at line 50 of file qstandardpaths.h.
This enum describes the different locations that can be queried using methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, and QStandardPaths::displayName.
Some of the values in this enum represent a user configuration. Such enum values will return the same paths in different applications, so they could be used to share data with other applications. Other values are specific to this application. Each enum value in the table below describes whether it's application-specific or generic.
Application-specific directories should be assumed to be unreachable by other applications. Therefore, files placed there might not be readable by other applications, even if run by the same user. On the other hand, generic directories should be assumed to be accessible by all applications run by this user, but should still be assumed to be unreachable by applications by other users.
Data interchange with other users is out of the scope of QStandardPaths.
\value DesktopLocation Returns the user's desktop directory. This is a generic value. On systems with no concept of a desktop, this is the same as QStandardPaths::HomeLocation. \value DocumentsLocation Returns the directory containing user document files. This is a generic value. The returned path is never empty. \value FontsLocation Returns the directory containing user's fonts. This is a generic value. Note that installing fonts may require additional, platform-specific operations. \value ApplicationsLocation Returns the directory containing the user applications (either executables, application bundles, or shortcuts to them). This is a generic value. Note that installing applications may require additional, platform-specific operations. Files, folders or shortcuts in this directory are platform-specific. \value MusicLocation Returns the directory containing the user's music or other audio files. This is a generic value. If no directory specific for music files exists, a sensible fallback for storing user documents is returned. \value MoviesLocation Returns the directory containing the user's movies and videos. This is a generic value. If no directory specific for movie files exists, a sensible fallback for storing user documents is returned. \value PicturesLocation Returns the directory containing the user's pictures or photos. This is a generic value. If no directory specific for picture files exists, a sensible fallback for storing user documents is returned. \value TempLocation Returns a directory where temporary files can be stored. The returned value might be application-specific, shared among other applications for this user, or even system-wide. The returned path is never empty. \value HomeLocation Returns the user's home directory (the same as QDir::homePath()). On Unix systems, this is equal to the HOME environment variable. This value might be generic or application-specific, but the returned path is never empty. \value AppLocalDataLocation Returns the local settings path on the Windows operating system. On all other platforms, it returns the same value as AppDataLocation. This enum value was added in Qt 5.4. \value CacheLocation Returns a directory location where user-specific non-essential (cached) data should be written. This is an application-specific directory. The returned path is never empty. \value GenericCacheLocation Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written. This is a generic value. Note that the returned path may be empty if the system has no concept of shared cache. \value GenericDataLocation Returns a directory location where persistent data shared across applications can be stored. This is a generic value. The returned path is never empty. \value RuntimeLocation Returns a directory location where runtime communication files should be written, like Unix local sockets. This is a generic value. The returned path may be empty on some systems. \value ConfigLocation Returns a directory location where user-specific configuration files should be written. This may be either a generic value or application-specific, and the returned path is never empty. \value DownloadLocation Returns a directory for user's downloaded files. This is a generic value. If no directory specific for downloads exists, a sensible fallback for storing user documents is returned. \value GenericConfigLocation Returns a directory location where user-specific configuration files shared between multiple applications should be written. This is a generic value and the returned path is never empty. \value AppDataLocation Returns a directory location where persistent application data can be stored. This is an application-specific directory. To obtain a path to store data to be shared with other applications, use QStandardPaths::GenericDataLocation. The returned path is never empty. On the Windows operating system, this returns the roaming path. This enum value was added in Qt 5.4. \value AppConfigLocation Returns a directory location where user-specific configuration files should be written. This is an application-specific directory, and the returned path is never empty. This enum value was added in Qt 5.5. \value PublicShareLocation Returns a directory location where user-specific publicly shared files and directories can be stored. This is a generic value. Note that the returned path may be empty if the system has no concept of a publicly shared location. This enum value was added in Qt 6.4. \value TemplatesLocation Returns a directory location where user-specific template files can be stored. This is a generic value. Note that the returned path may be empty if the system has no concept of a templates location. This enum value was added in Qt 6.4. \value [since 6.7] StateLocation Returns a directory location where user-specific application state data files should be written. This is an application-specific directory, and the returned path is never empty. \value [since 6.7] GenericStateLocation Returns a directory location where shared state data files across applications should be written. This value might be generic or application-specific, but the returned path is never empty.
The following table gives examples of paths on different operating systems. The first path is the writable path (unless noted). Other, additional paths, if any, represent non-writable locations.
\table \header
\table \header
\table \header
In the table above, <APPNAME> is usually the organization name, the application name, or both, or a unique name generated at packaging. Similarly, <APPROOT> is the location where this application is installed (often a sandbox). <APPDIR> is the directory containing the application executable.
The paths above should not be relied upon, as they may change according to OS configuration, locale, or they may change in future Qt versions.
"<USER>/DirName"
are not returned. Instead, you can use \l QFileDialog which uses the Storage Access Framework (SAF) to access such directories.{QStandardPaths::standardLocations(QStandardPaths::PicturesLocation)
.last()} as argument to \l{QFileDialog::setDirectory()}, a native image picker dialog will be used for accessing the user's photo album. The filename returned can be loaded using QFile and related APIs. This feature was added in Qt 5.5.Definition at line 20 of file qstandardpaths.h.
|
static |
displayName
Definition at line 557 of file qstandardpaths.cpp.
|
static |
findExecutable
Definition at line 509 of file qstandardpaths.cpp.
|
static |
Returns true
if test mode is enabled in QStandardPaths; otherwise returns false
.
Definition at line 632 of file qstandardpaths.cpp.
|
static |
locate
Definition at line 402 of file qstandardpaths.cpp.
|
static |
|
static |
setTestModeEnabled
Definition at line 619 of file qstandardpaths.cpp.
|
static |
standardLocations
Definition at line 227 of file qstandardpaths_android.cpp.
|
static |
writableLocation
Definition at line 180 of file qstandardpaths_android.cpp.