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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QProcessEnvironment Class Reference

The QProcessEnvironment class holds the environment variables that can be passed to a program. More...

 #include <QProcessEnvironment>

Note: All functions in this class are reentrant.

This class was introduced in Qt 4.6.

Public Functions

QProcessEnvironment ()
QProcessEnvironment ( const QProcessEnvironment & other )
~QProcessEnvironment ()
void clear ()
bool contains ( const QString & name ) const
void insert ( const QString & name, const QString & value )
bool isEmpty () const
void remove ( const QString & name )
QStringList toStringList () const
QString value ( const QString & name, const QString & defaultValue = QString() ) const
bool operator!= ( const QProcessEnvironment & other ) const
QProcessEnvironment & operator= ( const QProcessEnvironment & other )
bool operator== ( const QProcessEnvironment & other ) const

Static Public Members

QProcessEnvironment systemEnvironment ()

Detailed Description

The QProcessEnvironment class holds the environment variables that can be passed to a program.

A process's environment is composed of a set of key=value pairs known as environment variables. The QProcessEnvironment class wraps that concept and allows easy manipulation of those variables. It's meant to be used along with QProcess, to set the environment for child processes. It cannot be used to change the current process's environment.

The environment of the calling process can be obtained using QProcessEnvironment::systemEnvironment().

On Unix systems, the variable names are case-sensitive. For that reason, this class will not touch the names of the variables. Note as well that Unix environment allows both variable names and contents to contain arbitrary binary data (except for the NUL character), but this is not supported by QProcessEnvironment. This class only supports names and values that are encodable by the current locale settings (see QTextCodec::codecForLocale).

On Windows, the variable names are case-insensitive. Therefore, QProcessEnvironment will always uppercase the names and do case-insensitive comparisons.

On Windows CE, the concept of environment does not exist. This class will keep the values set for compatibility with other platforms, but the values set will have no effect on the processes being created.

See also QProcess, QProcess::systemEnvironment(), and QProcess::setProcessEnvironment().

Member Function Documentation

QProcessEnvironment::QProcessEnvironment ()

Creates a new QProcessEnvironment object. This constructor creates an empty environment. If set on a QProcess, this will cause the current environment variables to be removed.

QProcessEnvironment::QProcessEnvironment ( const QProcessEnvironment & other )

Creates a QProcessEnvironment object that is a copy of other.

QProcessEnvironment::~QProcessEnvironment ()

Frees the resources associated with this QProcessEnvironment object.

void QProcessEnvironment::clear ()

Removes all key=value pairs from this QProcessEnvironment object, making it empty.

See also isEmpty() and systemEnvironment().

bool QProcessEnvironment::contains ( const QString & name ) const

Returns true if the environment variable of name name is found in this QProcessEnvironment object.

On Windows, variable names are case-insensitive, so the key is converted to uppercase before searching. On other systems, names are case-sensitive so no trasformation is applied.

See also insert() and value().

void QProcessEnvironment::insert ( const QString & name, const QString & value )

Inserts the environment variable of name name and contents value into this QProcessEnvironment object. If that variable already existed, it is replaced by the new value.

On Windows, variable names are case-insensitive, so this function always uppercases the variable name before inserting. On other systems, names are case-sensitive, so no transformation is applied.

On most systems, inserting a variable with no contents will have the same effect for applications as if the variable had not been set at all. However, to guarantee that there are no incompatibilities, to remove a variable, please use the remove() function.

See also contains(), remove(), and value().

bool QProcessEnvironment::isEmpty () const

Returns true if this QProcessEnvironment object is empty: that is there are no key=value pairs set.

See also clear(), systemEnvironment(), and insert().

void QProcessEnvironment::remove ( const QString & name )

Removes the environment variable identified by name from this QProcessEnvironment object. If that variable did not exist before, nothing happens.

On Windows, variable names are case-insensitive, so the key is converted to uppercase before searching. On other systems, names are case-sensitive so no trasformation is applied.

See also contains(), insert(), and value().

QProcessEnvironment QProcessEnvironment::systemEnvironment () [static]

The systemEnvironment function returns the environment of the calling process.

It is returned as a QProcessEnvironment. This function does not cache the system environment. Therefore, it's possible to obtain an updated version of the environment if low-level C library functions like setenv ot putenv have been called.

However, note that repeated calls to this function will recreate the QProcessEnvironment object, which is a non-trivial operation.

This function was introduced in Qt 4.6.

See also QProcess::systemEnvironment().

QStringList QProcessEnvironment::toStringList () const

Converts this QProcessEnvironment object into a list of strings, one for each environment variable that is set. The environment variable's name and its value are separated by an equal character ('=').

The QStringList contents returned by this function are suitable for use with the QProcess::setEnvironment function. However, it is recommended to use QProcess::setProcessEnvironment instead since that will avoid unnecessary copying of the data.

See also systemEnvironment(), QProcess::systemEnvironment(), QProcess::environment(), and QProcess::setEnvironment().

QString QProcessEnvironment::value ( const QString & name, const QString & defaultValue = QString() ) const

Searches this QProcessEnvironment object for a variable identified by name and returns its value. If the variable is not found in this object, then defaultValue is returned instead.

On Windows, variable names are case-insensitive, so the key is converted to uppercase before searching. On other systems, names are case-sensitive so no trasformation is applied.

See also contains(), insert(), and remove().

bool QProcessEnvironment::operator!= ( const QProcessEnvironment & other ) const

Returns true if this and the other QProcessEnvironment objects are different.

See also operator==().

QProcessEnvironment & QProcessEnvironment::operator= ( const QProcessEnvironment & other )

Copies the contents of the other QProcessEnvironment object into this one.

bool QProcessEnvironment::operator== ( const QProcessEnvironment & other ) const

Returns true if this and the other QProcessEnvironment objects are equal.

Two QProcessEnvironment objects are considered equal if they have the same set of key=value pairs. The comparison of keys is done case-sensitive on platforms where the environment is case-sensitive.

See also operator!=() and contains().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Abusons de QMap

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 4.7-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