QProcessEnvironment¶
The
QProcessEnvironment
class holds the environment variables that can be passed to a program. More…
New in version 4.6.
Synopsis¶
Functions¶
Static functions¶
def
systemEnvironment
()
Detailed Description¶
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 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).
QProcessEnvironment
will 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.
QProcessEnvironment
behaves accordingly.
- class PySide2.QtCore.QProcessEnvironment¶
PySide2.QtCore.QProcessEnvironment(other)
- param other:
Creates a new
QProcessEnvironment
object. This constructor creates an empty environment. If set on aQProcess
, this will cause the current environment variables to be removed.Creates a
QProcessEnvironment
object that is a copy ofother
.
- PySide2.QtCore.QProcessEnvironment.clear()¶
Removes all key=value pairs from this
QProcessEnvironment
object, making it empty.See also
- PySide2.QtCore.QProcessEnvironment.contains(name)¶
- Parameters:
name – str
- Return type:
bool
Returns
true
if the environment variable of namename
is found in thisQProcessEnvironment
object.
- PySide2.QtCore.QProcessEnvironment.insert(e)¶
- Parameters:
This is an overloaded function.
Inserts the contents of
e
in thisQProcessEnvironment
object. Variables in this object that also exist ine
will be overwritten.
- PySide2.QtCore.QProcessEnvironment.insert(name, value)
- Parameters:
name – str
value – str
Inserts the environment variable of name
name
and contentsvalue
into thisQProcessEnvironment
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()
function.See also
- PySide2.QtCore.QProcessEnvironment.isEmpty()¶
- Return type:
bool
Returns
true
if thisQProcessEnvironment
object is empty: that is there are no key=value pairs set.See also
- PySide2.QtCore.QProcessEnvironment.keys()¶
- Return type:
list of strings
Returns a list containing all the variable names in this
QProcessEnvironment
object.
- PySide2.QtCore.QProcessEnvironment.__ne__(other)¶
- Parameters:
- Return type:
bool
Returns
true
if this and theother
QProcessEnvironment
objects are different.See also
operator==()
- PySide2.QtCore.QProcessEnvironment.__eq__(other)¶
- Parameters:
- Return type:
bool
Returns
true
if this and theother
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!=()
contains()
- PySide2.QtCore.QProcessEnvironment.remove(name)¶
- Parameters:
name – str
Removes the environment variable identified by
name
from thisQProcessEnvironment
object. If that variable did not exist before, nothing happens.See also
- PySide2.QtCore.QProcessEnvironment.swap(other)¶
- Parameters:
Swaps this process environment instance with
other
. This function is very fast and never fails.
- static PySide2.QtCore.QProcessEnvironment.systemEnvironment()¶
- Return type:
The 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 likesetenv
orputenv
have been called.However, note that repeated calls to this function will recreate the
QProcessEnvironment
object, which is a non-trivial operation.See also
- PySide2.QtCore.QProcessEnvironment.toStringList()¶
- Return type:
list of strings
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 presentation. Use with thesetEnvironment
function is not recommended due to potential encoding problems under Unix, and worse performance.
- PySide2.QtCore.QProcessEnvironment.value(name[, defaultValue=""])¶
- Parameters:
name – str
defaultValue – str
- Return type:
str
Searches this
QProcessEnvironment
object for a variable identified byname
and returns its value. If the variable is not found in this object, thendefaultValue
is returned instead.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.