QStandardPaths ClassThe QStandardPaths class provides methods for accessing standard paths. More... #include <QStandardPaths> This class was introduced in Qt 5.0. Public Types
Static Public Members
Detailed DescriptionThe 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. Member Type Documentation
flags QStandardPaths::LocateOptions |
Constant | Value | Description |
---|---|---|
QStandardPaths::LocateFile | 0x0 | return only files |
QStandardPaths::LocateDirectory | 0x1 | return only directories |
The LocateOptions type is a typedef for QFlags<LocateOption>. It stores an OR combination of LocateOption values.
This enum describes the different locations that can be queried using methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, and QStandardPaths::displayName.
Constant | Value | Description |
---|---|---|
QStandardPaths::DesktopLocation | 0 | Returns the user's desktop directory. |
QStandardPaths::DocumentsLocation | 1 | Returns the user's document. |
QStandardPaths::FontsLocation | 2 | Returns the user's fonts. |
QStandardPaths::ApplicationsLocation | 3 | Returns the user's applications. |
QStandardPaths::MusicLocation | 4 | Returns the user's music. |
QStandardPaths::MoviesLocation | 5 | Returns the user's movies. |
QStandardPaths::PicturesLocation | 6 | Returns the user's pictures. |
QStandardPaths::TempLocation | 7 | Returns the system's temporary directory. |
QStandardPaths::HomeLocation | 8 | Returns the user's home directory. |
QStandardPaths::DataLocation | 9 | Returns a directory location where persistent application data can be stored. QCoreApplication::organizationName and QCoreApplication::applicationName are appended to the directory location returned for GenericDataLocation. |
QStandardPaths::CacheLocation | 10 | Returns a directory location where user-specific non-essential (cached) data should be written. |
QStandardPaths::GenericCacheLocation | 15 | Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written. |
QStandardPaths::GenericDataLocation | 11 | Returns a directory location where persistent data shared across applications can be stored. |
QStandardPaths::RuntimeLocation | 12 | Returns a directory location where runtime communication files should be written. For instance unix local sockets. |
QStandardPaths::ConfigLocation | 13 | Returns a directory location where user-specific configuration files should be written. |
QStandardPaths::DownloadLocation | 14 | Returns a directory for user's downloaded files. |
See also writableLocation(), standardLocations(), displayName(), locate(), and locateAll().
Returns a localized display name for the given location type or an empty QString if no relevant location can be found.
Enables "test mode" in QStandardPaths, which changes writable locations to point to test directories, in order to prevent auto tests from reading from or writing to the current user's configuration.
This affects the locations into which test programs might write files: GenericDataLocation, DataLocation, ConfigLocation, GenericCacheLocation, CacheLocation. Other locations are not affected.
On Unix, XDG_DATA_HOME is set to ~/.qttest/share, XDG_CONFIG_HOME is set to ~/.qttest/config, and XDG_CACHE_HOME is set to ~/.qttest/cache.
On Mac, data goes to "~/.qttest/Application Support", cache goes to ~/.qttest/Cache, and config goes to ~/.qttest/Preferences.
On Windows, everything goes to a "qttest" directory under Application Data.
Finds the executable named executableName in the paths specified by paths, or the system paths if paths is empty.
On most operating systems the system path is determined by the PATH environment variable.
The directories where to search for the executable can be set in the paths argument. To search in both your own paths and the system paths, call findExecutable twice, once with paths set and once with paths empty.
Symlinks are not resolved, in order to preserve behavior for the case of executables whose behavior depends on the name they are invoked with.
Note: On Windows, the usual executable extensions (from the PATHEXT environment variable) are automatically appended, so that for instance findExecutable("foo") will find foo.exe or foo.bat if present.
Returns the absolute file path to the executable, or an empty string if not found.
Tries to find a file or directory called fileName in the standard locations for type.
The full path to the first file or directory (depending on options) found is returned. If no such file or directory can be found, an empty string is returned.
Tries to find all files or directories called fileName in the standard locations for type.
The options flag allows to specify whether to look for files or directories.
Returns the list of all the files that were found.
Returns all the directories where files of type belong.
Much like the PATH variable, it returns the directories in order of priority, starting with the user-specific writableLocation() for the type.
Returns the directory where files of type should be written to, or an empty string if the location cannot be determined.
Note: The storage location returned can be a directory that does not exist; i.e., it may need to be created by the system or the user.