QProcessEnvironment Class Reference

[ QtCore module]

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

方法

Static Methods

Special Methods


详细描述

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.


方法文档编制

QProcessEnvironment.__init__ ( self )

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

QProcessEnvironment.__init__ ( self , QProcessEnvironment   other )

创建 QProcessEnvironment object that is a copy of other .

QProcessEnvironment.clear ( self )

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

另请参阅 isEmpty () 和 systemEnvironment ().

bool QProcessEnvironment.contains ( self , QString  name )

Returns true if the environment variable of name name is found in this QProcessEnvironment 对象。

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.

另请参阅 insert () 和 value ().

QProcessEnvironment.insert ( self , QString  name , 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 () 函数。

另请参阅 contains (), remove (),和 value ().

QProcessEnvironment.insert ( self , QProcessEnvironment   e )

这是重载函数。

Inserts the contents of e in this QProcessEnvironment 对象。 Variables in this object that also exist in e 将是 overwritten.

该函数在 Qt 4.8 引入。

bool QProcessEnvironment.isEmpty ( self )

返回 true,若此 QProcessEnvironment object is empty: that is there are no key=value pairs set.

另请参阅 clear (), systemEnvironment (), and insert ().

QStringList QProcessEnvironment.keys ( self )

返回包含所有变量名称的列表在此 QProcessEnvironment 对象。

该函数在 Qt 4.8 引入。

QProcessEnvironment.remove ( self , QString  name )

移除环境变量标识通过 name from this QProcessEnvironment 对象。若变量之前不存在,什么都不发生。

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.

另请参阅 contains (), insert (),和 value ().

QProcessEnvironment QProcessEnvironment.systemEnvironment ()

The systemEnvironment function returns the environment of the calling process.

它被返回作为 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.

该函数在 Qt 4.6 引入。

另请参阅 QProcess.systemEnvironment ().

QStringList QProcessEnvironment.toStringList ( self )

转换此 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 ('=').

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.

另请参阅 systemEnvironment (), QProcess.systemEnvironment (), QProcess.environment (), and QProcess.setEnvironment ().

QString QProcessEnvironment.value ( self , QString  name , QString  defaultValue  = QString())

搜索此 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.

另请参阅 contains (), insert (),和 remove ().

bool QProcessEnvironment.__eq__ ( self , QProcessEnvironment   other )

bool QProcessEnvironment.__ne__ ( self , QProcessEnvironment   other )