- Qt 5.15
- Qt Core
- C++ Classes
- QProcess
- Qt 5.15.18 Reference Documentation

# 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)` Q_PID | pid() 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)

## Signals

`(obsolete)` void | error(QProcess::ProcessError error)
`(obsolete)` void | finished(int exitCode)

## Static Public Members

`(obsolete)` int | execute(const QString &command)
`(obsolete)` bool | startDetached(const QString &command)

## Member Function Documentation

### `[signal]` void QProcess::error(QProcess::ProcessError error)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use errorOccurred() instead.

Note: Signal error is overloaded in this class. To connect to this signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:

     connect(process, QOverload<QProcess::ProcessError>::of(&QProcess::error),
         [=](QProcess::ProcessError error){ /* ... */ });

### `[signal]` void QProcess::finished(int exitCode)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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 signal by using the function pointer syntax, Qt provides a convenient helper for obtaining the function pointer as shown in this example:

     connect(process, QOverload<int>::of(&QProcess::finished),
         [=](int exitCode){ /* ... */ });

### QStringList QProcess::environment() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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().

### `[static]` int QProcess::execute(const QString &command)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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().

### Q_PID QProcess::pid() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use processId() instead.

Returns the native process identifier for the running process, if available. If no process is currently running, `0` is returned.

Note: Unlike processId(), pid() returns an integer on Unix and a pointer on Windows.

See also Q_PID and processId().

### ProcessChannelMode QProcess::readChannelMode() const

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Use setProcessChannelMode(mode) instead.

See also readChannelMode() and setProcessChannelMode().

### void QProcess::start(const QString &command, OpenMode mode = ReadWrite)

This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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 is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

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().