注意
该类在 Qt4.6 引入
PySide.QtCore.QProcessEnvironment 类保持可以被传递给程序的环境变量。
A process's environment is composed of a set of key=value pairs known as environment variables. The PySide.QtCore.QProcessEnvironment class wraps that concept and allows easy manipulation of those variables. It's meant to be used along with PySide.QtCore.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 PySide.QtCore.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, PySide.QtCore.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.
| 参数: | other – PySide.QtCore.QProcessEnvironment |
|---|
创建新 PySide.QtCore.QProcessEnvironment object. This constructor creates an empty environment. If set on a PySide.QtCore.QProcess , this will cause the current environment variables to be removed.
创建 PySide.QtCore.QProcessEnvironment object that is a copy of other .
Removes all key=value pairs from this PySide.QtCore.QProcessEnvironment object, making it empty.
| 参数: | name – unicode |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if the environment variable of name name 被找到在此 PySide.QtCore.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.
| 参数: | e – PySide.QtCore.QProcessEnvironment |
|---|
这是重载函数。
Inserts the contents of e in this PySide.QtCore.QProcessEnvironment object. Variables in this object that also exist in e will be overwritten.
| 参数: |
|
|---|
Inserts the environment variable of name name and contents value into this PySide.QtCore.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 PySide.QtCore.QProcessEnvironment.remove() 函数。
| 返回类型: | PySide.QtCore.bool |
|---|
返回 true,若此 PySide.QtCore.QProcessEnvironment 对象为空:没有设置键=值对。
| 返回类型: | 字符串列表 |
|---|
返回包含所有变量名称的列表在此 PySide.QtCore.QProcessEnvironment 对象。
| 参数: | other – PySide.QtCore.QProcessEnvironment |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if this and the other PySide.QtCore.QProcessEnvironment objects are different.
另请参阅
PySide.QtCore.QProcessEnvironment.operator==()
| 参数: | other – PySide.QtCore.QProcessEnvironment |
|---|---|
| 返回类型: | PySide.QtCore.bool |
Returns true if this and the other PySide.QtCore.QProcessEnvironment 对象是相等的。
Two PySide.QtCore.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.
另请参阅
PySide.QtCore.QProcessEnvironment.operator!=() PySide.QtCore.QProcessEnvironment.contains()
| 参数: | name – unicode |
|---|
移除环境变量标识通过 name 从此 PySide.QtCore.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.
| 返回类型: | PySide.QtCore.QProcessEnvironment |
|---|
The systemEnvironment function returns the environment of the calling process.
它被返回作为 PySide.QtCore.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 有被调用。
However, note that repeated calls to this function will recreate the PySide.QtCore.QProcessEnvironment object, which is a non-trivial operation.
| 返回类型: | 字符串列表 |
|---|
转换此 PySide.QtCore.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 (‘=').
PySide.QtCore.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.
| 参数: |
|
|---|---|
| 返回类型: |
unicode |
搜索此 PySide.QtCore.QProcessEnvironment object for a variable identified by name and returns its value. If the variable is not found in this object, then defaultValue 被返回取而代之。
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.