QProcessEnvironment类保持可以被传递给程序的环境变量。 更多 …
4.6 版新增。
A process’s environment is composed of a set of key=value pairs known as environment variables. The
QProcessEnvironmentclass wraps that concept and allows easy manipulation of those variables. It’s meant to be used along withQProcess, 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
systemEnvironment().On Unix systems, the variable names are case-sensitive. Note that the Unix environment allows both variable names and contents to contain arbitrary binary data (except for the NUL character).
QProcessEnvironmentwill preserve such variables, but does not support manipulating variables whose names or values cannot be encoded by the current locale settings (seecodecForLocale).On Windows, the variable names are case-insensitive, but case-preserving.
QProcessEnvironmentbehaves accordingly.
QProcessEnvironment
¶
QProcessEnvironment(other)
- param other
创建新
QProcessEnvironment
object. This constructor creates an empty environment. If set on a
QProcess
, this will cause the current environment variables to be removed.
创建
QProcessEnvironment
object that is a copy of
other
.
PySide2.QtCore.QProcessEnvironment.
clear
(
)
¶
Removes all key=value pairs from this
QProcessEnvironment
object, making it empty.
PySide2.QtCore.QProcessEnvironment.
contains
(
name
)
¶
name – unicode
bool
返回
true
若环境变量名
name
被找到在此
QProcessEnvironment
对象。
PySide2.QtCore.QProcessEnvironment.
insert
(
e
)
¶
这是重载函数。
Inserts the contents of
e
in this
QProcessEnvironment
object. Variables in this object that also exist in
e
will be overwritten.
PySide2.QtCore.QProcessEnvironment.
insert
(
name
,
value
)
¶
name – unicode
value – unicode
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 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()
函数。
另请参阅
PySide2.QtCore.QProcessEnvironment.
isEmpty
(
)
¶
bool
返回
true
若此
QProcessEnvironment
对象为空:没有设置键=值对。
PySide2.QtCore.QProcessEnvironment.
keys
(
)
¶
字符串列表
返回包含所有变量名称的列表在此
QProcessEnvironment
对象。
PySide2.QtCore.QProcessEnvironment.
__ne__
(
other
)
¶
other
–
QProcessEnvironment
bool
返回
true
若此和
other
QProcessEnvironment
objects are different.
另请参阅
operator==()
PySide2.QtCore.QProcessEnvironment.
__eq__
(
other
)
¶
other
–
QProcessEnvironment
bool
返回
true
若此和
other
QProcessEnvironment
对象是相等的。
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.
另请参阅
operator!=()
contains()
PySide2.QtCore.QProcessEnvironment.
remove
(
name
)
¶
name – unicode
移除环境变量标识通过
name
从此
QProcessEnvironment
对象。若变量之前不存在,什么都不发生。
另请参阅
PySide2.QtCore.QProcessEnvironment.
swap
(
other
)
¶
other
–
QProcessEnvironment
交换此进程环境实例与
other
。此函数非常快,且从不失败。
PySide2.QtCore.QProcessEnvironment.
systemEnvironment
(
)
¶
函数返回调用进程的环境。
它被返回作为
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
or
putenv
有被调用。
However, note that repeated calls to this function will recreate the
QProcessEnvironment
object, which is a non-trivial operation.
另请参阅
PySide2.QtCore.QProcessEnvironment.
toStringList
(
)
¶
字符串列表
转换此
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 presentation. Use with the
setEnvironment
function is not recommended due to potential encoding problems under Unix, and worse performance.
PySide2.QtCore.QProcessEnvironment.
value
(
name
[
,
defaultValue=""
]
)
¶
name – unicode
defaultValue – unicode
unicode
搜索此
QProcessEnvironment
object for a variable identified by
name
and returns its value. If the variable is not found in this object, then
defaultValue
被返回取而代之。
另请参阅