Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QStandardPaths Class

The QStandardPaths class provides methods for accessing standard paths. More...

 #include <QStandardPaths>

This class was introduced in Qt 5.0.

Public Types

enum LocateOption { LocateFile, LocateDirectory }
flags LocateOptions
enum StandardLocation { DesktopLocation, DocumentsLocation, FontsLocation, ApplicationsLocation, ..., DownloadLocation }

Static Public Members

QString displayName(StandardLocation type)
void enableTestMode(bool testMode)
QString findExecutable(const QString & executableName, const QStringList & paths = QStringList())
QString locate(StandardLocation type, const QString & fileName, LocateOptions options = LocateFile)
QStringList locateAll(StandardLocation type, const QString & fileName, LocateOptions options = LocateFile)
QStringList standardLocations(StandardLocation type)
QString writableLocation(StandardLocation type)

Detailed Description

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.

Member Type Documentation

enum QStandardPaths::LocateOption
flags QStandardPaths::LocateOptions

This enum describes the different flags that can be used for controlling the behavior of QStandardPaths::locate and QStandardPaths::locateAll.

ConstantValueDescription
QStandardPaths::LocateFile0x0return only files
QStandardPaths::LocateDirectory0x1return only directories

The LocateOptions type is a typedef for QFlags<LocateOption>. It stores an OR combination of LocateOption values.

enum QStandardPaths::StandardLocation

This enum describes the different locations that can be queried using methods such as QStandardPaths::writableLocation, QStandardPaths::standardLocations, and QStandardPaths::displayName.

ConstantValueDescription
QStandardPaths::DesktopLocation0Returns the user's desktop directory.
QStandardPaths::DocumentsLocation1Returns the user's document.
QStandardPaths::FontsLocation2Returns the user's fonts.
QStandardPaths::ApplicationsLocation3Returns the user's applications.
QStandardPaths::MusicLocation4Returns the user's music.
QStandardPaths::MoviesLocation5Returns the user's movies.
QStandardPaths::PicturesLocation6Returns the user's pictures.
QStandardPaths::TempLocation7Returns the system's temporary directory.
QStandardPaths::HomeLocation8Returns the user's home directory.
QStandardPaths::DataLocation9Returns 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::CacheLocation10Returns a directory location where user-specific non-essential (cached) data should be written.
QStandardPaths::GenericCacheLocation15Returns a directory location where user-specific non-essential (cached) data, shared across applications, should be written.
QStandardPaths::GenericDataLocation11Returns a directory location where persistent data shared across applications can be stored.
QStandardPaths::RuntimeLocation12Returns a directory location where runtime communication files should be written. For instance unix local sockets.
QStandardPaths::ConfigLocation13Returns a directory location where user-specific configuration files should be written.
QStandardPaths::DownloadLocation14Returns a directory for user's downloaded files.

See also writableLocation(), standardLocations(), displayName(), locate(), and locateAll().

Member Function Documentation

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

Returns a localized display name for the given location type or an empty QString if no relevant location can be found.

void QStandardPaths::enableTestMode(bool testMode) [static]

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.

QString QStandardPaths::findExecutable(const QString & executableName, const QStringList & paths = QStringList()) [static]

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.

QString QStandardPaths::locate(StandardLocation type, const QString & fileName, LocateOptions options = LocateFile) [static]

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.

QStringList QStandardPaths::locateAll(StandardLocation type, const QString & fileName, LocateOptions options = LocateFile) [static]

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.

QStringList QStandardPaths::standardLocations(StandardLocation type) [static]

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.

QString QStandardPaths::writableLocation(StandardLocation type) [static]

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.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web