Obsolete Members for QProcess
The following members of class QProcess are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.
Public Functions
(obsolete) QStringList | environment() const |
(obsolete) ProcessChannelMode | readChannelMode() const |
(obsolete) void | setEnvironment(const QStringList &environment) |
(obsolete) void | setReadChannelMode(ProcessChannelMode mode) |
(obsolete) void | start(const QString &command, OpenMode mode = ReadWrite) |
- 2 public functions inherited from QObject
Signals
Static Public Members
(obsolete) int | execute(const QString &command) |
(obsolete) bool | startDetached(const QString &command) |
- 1 static public member inherited from QObject
Member Function Documentation
QStringList QProcess::environment() const
Returns the environment that QProcess will pass to its child process, or an empty QStringList if no environment has been set using setEnvironment(). If no environment has been set, the environment of the calling process will be used.
See also processEnvironment(), setEnvironment(), and systemEnvironment().
[signal] void QProcess::error(QProcess::ProcessError error)
Use errorOccurred() instead.
Note: Signal error is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(process, static_cast<void(QProcess::*)(QProcess::ProcessError)>(&QProcess::error), [=](QProcess::ProcessError error){ /* ... */ });
[static] int QProcess::execute(const QString &command)
This is an overloaded function.
Starts the program command in a new process, waits for it to finish, and then returns the exit code.
Argument handling is identical to the respective start() overload.
After the command string has been split and unquoted, this function behaves like the overload which takes the arguments as a string list.
See also start() and splitCommand().
[signal] void QProcess::finished(int exitCode)
This is an overloaded function.
Use finished(int exitCode, QProcess::ExitStatus status) instead.
Note: Signal finished is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:
connect(process, static_cast<void(QProcess::*)(int)>(&QProcess::finished), [=](int exitCode){ /* ... */ });
ProcessChannelMode QProcess::readChannelMode() const
Returns the read channel mode of the QProcess. This function is equivalent to processChannelMode()
See also setReadChannelMode() and processChannelMode().
void QProcess::setEnvironment(const QStringList &environment)
Sets the environment that QProcess will pass to the child process. The parameter environment is a list of key=value pairs.
For example, the following code adds the environment variable TMPDIR:
QProcess process; QStringList env = QProcess::systemEnvironment(); env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable process.setEnvironment(env); process.start("myapp");
Note: This function is less efficient than the setProcessEnvironment() function.
See also environment(), setProcessEnvironment(), and systemEnvironment().
void QProcess::setReadChannelMode(ProcessChannelMode mode)
Use setProcessChannelMode(mode) instead.
See also readChannelMode() and setProcessChannelMode().
void QProcess::start(const QString &command, OpenMode mode = ReadWrite)
This is an overloaded function.
Starts the command command in a new process. The OpenMode is set to mode.
command is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces. For example:
QProcess process; process.start("del /s *.txt"); // same as process.start("del", QStringList() << "/s" << "*.txt"); ...
Arguments containing spaces must be quoted to be correctly supplied to the new process. For example:
QProcess process; process.start("dir \"My Documents\"");
Literal quotes in the command string are represented by triple quotes. For example:
QProcess process; process.start("dir \"Epic 12\"\"\" Singles\"");
After the command string has been split and unquoted, this function behaves like the overload which takes the arguments as a string list.
You can disable this overload by defining QT_NO_PROCESS_COMBINED_ARGUMENT_START when you compile your applications. This can be useful if you want to ensure that you are not splitting arguments unintentionally, for example. In virtually all cases, using the other overload is the preferred method.
On operating systems where the system API for passing command line arguments to a subprocess natively uses a single string (Windows), one can conceive command lines which cannot be passed via QProcess's portable list-based API. In these rare cases you need to use setProgram() and setNativeArguments() instead of this function.
See also splitCommand().
[static] bool QProcess::startDetached(const QString &command)
This function overloads startDetached().
Starts the command command in a new process, and detaches from it. Returns true on success; otherwise returns false.
Argument handling is identical to the respective start() overload.
After the command string has been split and unquoted, this function behaves like the overload which takes the arguments as a string list.
See also start(const QString &command, QIODevice::OpenMode mode) and splitCommand().