
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQProcess class is used to start external programs and to communicate with them.More...
| Header: | #include <QProcess> |
| Inherits: | QIODevice |
Note: All functions in this class arereentrant.
| enum | ExitStatus { NormalExit, CrashExit } |
| enum | ProcessChannel { StandardOutput, StandardError } |
| enum | ProcessChannelMode { SeparateChannels, MergedChannels, ForwardedChannels } |
| enum | ProcessError { FailedToStart, Crashed, Timedout, WriteError, ReadError, UnknownError } |
| enum | ProcessState { NotRunning, Starting, Running } |
| QProcess(QObject * parent = 0) | |
| virtual | ~QProcess() |
| void | closeReadChannel(ProcessChannel channel) |
| void | closeWriteChannel() |
| QProcess::ProcessError | error() const |
| int | exitCode() const |
| QProcess::ExitStatus | exitStatus() const |
| QString | nativeArguments() const |
| Q_PID | pid() const |
| ProcessChannelMode | processChannelMode() const |
| QProcessEnvironment | processEnvironment() const |
| QByteArray | readAllStandardError() |
| QByteArray | readAllStandardOutput() |
| ProcessChannel | readChannel() const |
| void | setNativeArguments(const QString & arguments) |
| void | setProcessChannelMode(ProcessChannelMode mode) |
| void | setProcessEnvironment(const QProcessEnvironment & environment) |
| void | setReadChannel(ProcessChannel channel) |
| void | setStandardErrorFile(const QString & fileName, OpenMode mode = Truncate) |
| void | setStandardInputFile(const QString & fileName) |
| void | setStandardOutputFile(const QString & fileName, OpenMode mode = Truncate) |
| void | setStandardOutputProcess(QProcess * destination) |
| void | setWorkingDirectory(const QString & dir) |
| void | start(const QString & program, const QStringList & arguments, OpenMode mode = ReadWrite) |
| void | start(const QString & program, OpenMode mode = ReadWrite) |
| QProcess::ProcessState | state() const |
| bool | waitForFinished(int msecs = 30000) |
| bool | waitForStarted(int msecs = 30000) |
| QString | workingDirectory() const |
| virtual bool | atEnd() const |
| virtual qint64 | bytesAvailable() const |
| virtual qint64 | bytesToWrite() const |
| virtual bool | canReadLine() const |
| virtual void | close() |
| virtual bool | isSequential() const |
| virtual bool | waitForBytesWritten(int msecs = 30000) |
| virtual bool | waitForReadyRead(int msecs = 30000) |
| void | error(QProcess::ProcessError error) |
| void | finished(int exitCode, QProcess::ExitStatus exitStatus) |
| void | readyReadStandardError() |
| void | readyReadStandardOutput() |
| void | started() |
| void | stateChanged(QProcess::ProcessState newState) |
| int | execute(const QString & program, const QStringList & arguments) |
| int | execute(const QString & program) |
| bool | startDetached(const QString & program, const QStringList & arguments, const QString & workingDirectory, qint64 * pid = 0) |
| bool | startDetached(const QString & program, const QStringList & arguments) |
| bool | startDetached(const QString & program) |
| QStringList | systemEnvironment() |
| void | setProcessState(ProcessState state) |
| virtual void | setupChildProcess() |
| virtual qint64 | readData(char * data, qint64 maxlen) |
| virtual qint64 | writeData(const char * data, qint64 len) |
| typedef | Q_PID |
TheQProcess class is used to start external programs and to communicate with them.
To start a process, pass the name and command line arguments of the program you want to run as arguments tostart(). Arguments are supplied as individual strings in aQStringList.
For example, the following code snippet runs the analog clock example in the Motif style on X11 platforms by passing strings containing "-style" and "motif" as two items in the list of arguments:
QObject*parent; ...QString program="./path/to/Qt/examples/widgets/analogclock";QStringList arguments; arguments<<"-style"<<"motif";QProcess*myProcess=newQProcess(parent); myProcess->start(program, arguments);
QProcess then enters theStarting state, and when the program has started,QProcess enters theRunning state and emitsstarted().
QProcess allows you to treat a process as a sequential I/O device. You can write to and read from the process just as you would access a network connection usingQTcpSocket. You can then write to the process's standard input by callingwrite(), and read the standard output by callingread(),readLine(), andgetChar(). Because it inheritsQIODevice,QProcess can also be used as an input source forQXmlReader, or for generating data to be uploaded usingQFtp.
Note:On Windows CE and Symbian, reading and writing to a process is not supported.
When the process exits,QProcess reenters theNotRunning state (the initial state), and emitsfinished().
Thefinished() signal provides the exit code and exit status of the process as arguments, and you can also callexitCode() to obtain the exit code of the last process that finished, andexitStatus() to obtain its exit status. If an error occurs at any point in time,QProcess will emit theerror() signal. You can also callerror() to find the type of error that occurred last, andstate() to find the current process state.
Processes have two predefined output channels: The standard output channel (stdout) supplies regular console output, and the standard error channel (stderr) usually supplies the errors that are printed by the process. These channels represent two separate streams of data. You can toggle between them by callingsetReadChannel().QProcess emitsreadyRead() when data is available on the current read channel. It also emitsreadyReadStandardOutput() when new standard output data is available, and when new standard error data is available,readyReadStandardError() is emitted. Instead of callingread(),readLine(), orgetChar(), you can explicitly read all data from either of the two channels by callingreadAllStandardOutput() orreadAllStandardError().
The terminology for the channels can be misleading. Be aware that the process's output channels correspond toQProcess'sread channels, whereas the process's input channels correspond toQProcess'swrite channels. This is because what we read usingQProcess is the process's output, and what we write becomes the process's input.
QProcess can merge the two output channels, so that standard output and standard error data from the running process both use the standard output channel. CallsetProcessChannelMode() withMergedChannels before starting the process to activative this feature. You also have the option of forwarding the output of the running process to the calling, main process, by passingForwardedChannels as the argument.
Certain processes need special environment settings in order to operate. You can set environment variables for your process by calling setEnvironment(). To set a working directory, callsetWorkingDirectory(). By default, processes are run in the current working directory of the calling process.
Note:On Symbian, setting environment or working directory is not supported. The working directory will always be the private directory of the running process.
Note:On QNX, setting the working directory may cause all application threads, with the exception of theQProcess caller thread, to temporarily freeze, owing to a limitation in the operating system.
QProcess provides a set of functions which allow it to be used without an event loop, by suspending the calling thread until certain signals are emitted:
Calling these functions from the main thread (the thread that callsQApplication::exec()) may cause your user interface to freeze.
The following example runsgzip to compress the string "Qt rocks!", without an event loop:
QProcess gzip; gzip.start("gzip",QStringList()<<"-c");if (!gzip.waitForStarted())returnfalse; gzip.write("Qt rocks!"); gzip.closeWriteChannel();if (!gzip.waitForFinished())returnfalse;QByteArray result= gzip.readAll();
Some Windows commands (for example,dir) are not provided by separate applications, but by the command interpreter itself. If you attempt to useQProcess to execute these commands directly, it won't work. One possible solution is to execute the command interpreter itself (cmd.exe on some Windows systems), and ask the interpreter to execute the desired command.
On Symbian, processes which use the functionskill() orterminate() must have thePowerMgmt platform security capability. If the client process lacks this capability, these functions will fail.
Platform security capabilities are added via theTARGET.CAPABILITY qmake variable.
See alsoQBuffer,QFile, andQTcpSocket.
This enum describes the different exit statuses ofQProcess.
| Constant | Value | Description |
|---|---|---|
QProcess::NormalExit | 0 | The process exited normally. |
QProcess::CrashExit | 1 | The process crashed. |
See alsoexitStatus().
This enum describes the process channels used by the running process. Pass one of these values tosetReadChannel() to set the current read channel ofQProcess.
| Constant | Value | Description |
|---|---|---|
QProcess::StandardOutput | 0 | The standard output (stdout) of the running process. |
QProcess::StandardError | 1 | The standard error (stderr) of the running process. |
See alsosetReadChannel().
This enum describes the process channel modes ofQProcess. Pass one of these values tosetProcessChannelMode() to set the current read channel mode.
| Constant | Value | Description |
|---|---|---|
QProcess::SeparateChannels | 0 | QProcess manages the output of the running process, keeping standard output and standard error data in separate internal buffers. You can select theQProcess's current read channel by callingsetReadChannel(). This is the default channel mode ofQProcess. |
QProcess::MergedChannels | 1 | QProcess merges the output of the running process into the standard output channel (stdout). The standard error channel (stderr) will not receive any data. The standard output and standard error data of the running process are interleaved. |
QProcess::ForwardedChannels | 2 | QProcess forwards the output of the running process onto the main process. Anything the child process writes to its standard output and standard error will be written to the standard output and standard error of the main process. |
See alsosetProcessChannelMode().
This enum describes the different types of errors that are reported byQProcess.
| Constant | Value | Description |
|---|---|---|
QProcess::FailedToStart | 0 | The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program. |
QProcess::Crashed | 1 | The process crashed some time after starting successfully. |
QProcess::Timedout | 2 | The last waitFor...() function timed out. The state ofQProcess is unchanged, and you can try calling waitFor...() again. |
QProcess::WriteError | 4 | An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. |
QProcess::ReadError | 3 | An error occurred when attempting to read from the process. For example, the process may not be running. |
QProcess::UnknownError | 5 | An unknown error occurred. This is the default return value oferror(). |
See alsoerror().
This enum describes the different states ofQProcess.
| Constant | Value | Description |
|---|---|---|
QProcess::NotRunning | 0 | The process is not running. |
QProcess::Starting | 1 | The process is starting, but the program has not yet been invoked. |
QProcess::Running | 2 | The process is running and is ready for reading and writing. |
See alsostate().
Constructs aQProcess object with the givenparent.
[virtual]QProcess::~QProcess()Destructs theQProcess object, i.e., killing the process.
Note that this function will not return until the process is terminated.
[virtual]bool QProcess::atEnd() constReimplemented fromQIODevice::atEnd().
Returns true if the process is not running, and no more data is available for reading; otherwise returns false.
[virtual]qint64 QProcess::bytesAvailable() constReimplemented fromQIODevice::bytesAvailable().
[virtual]qint64 QProcess::bytesToWrite() constReimplemented fromQIODevice::bytesToWrite().
[virtual]bool QProcess::canReadLine() constReimplemented fromQIODevice::canReadLine().
This function operates on the current read channel.
See alsoreadChannel() andsetReadChannel().
[virtual]void QProcess::close()Reimplemented fromQIODevice::close().
Closes all communication with the process and kills it. After calling this function,QProcess will no longer emitreadyRead(), and data can no longer be read or written.
Closes the read channelchannel. After calling this function,QProcess will no longer receive data on the channel. Any data that has already been received is still available for reading.
Call this function to save memory, if you are not interested in the output of the process.
See alsocloseWriteChannel() andsetReadChannel().
Schedules the write channel ofQProcess to be closed. The channel will close once all data has been written to the process. After calling this function, any attempts to write to the process will fail.
Closing the write channel is necessary for programs that read input data until the channel has been closed. For example, the program "more" is used to display text data in a console on both Unix and Windows. But it will not display the text data untilQProcess's write channel has been closed. Example:
QProcess more;more.start("more");more.write("Text to display");more.closeWriteChannel();// QProcess will emit readyRead() once "more" starts printing
The write channel is implicitly opened whenstart() is called.
See alsocloseReadChannel().
Returns the type of error that occurred last.
See alsostate().
[signal]void QProcess::error(QProcess::ProcessError error)This signal is emitted when an error occurs with the process. The specifiederror describes the type of error that occurred.
Note:Signalerror 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(constQString & program, constQStringList & arguments)Starts the programprogram with the argumentsarguments in a new process, waits for it to finish, and then returns the exit code of the process. Any data the new process writes to the console is forwarded to the calling process.
The environment and working directory are inherited from the calling process.
On Windows, arguments that contain spaces are wrapped in quotes.
If the process cannot be started, -2 is returned. If the process crashes, -1 is returned. Otherwise, the process' exit code is returned.
[static]int QProcess::execute(constQString & program)This is an overloaded function.
Starts the programprogram in a new process.program is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces.
Returns the exit code of the last process that finished.
Returns the exit status of the last process that finished.
On Windows, if the process was terminated with TerminateProcess() from another application this function will still returnNormalExit unless the exit code is less than 0.
This function was introduced in Qt 4.1.
[signal]void QProcess::finished(int exitCode,QProcess::ExitStatus exitStatus)This signal is emitted when the process finishes.exitCode is the exit code of the process, andexitStatus is the exit status. After the process has finished, the buffers inQProcess are still intact. You can still read any data that the process may have written before it finished.
Note:Signalfinished 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::ExitStatus)>(&QProcess::finished),[=](int exitCode,QProcess::ExitStatus exitStatus){/* ... */ });
See alsoexitStatus().
[virtual]bool QProcess::isSequential() constReimplemented fromQIODevice::isSequential().
[slot]void QProcess::kill()Kills the current process, causing it to exit immediately.
On Windows, kill() uses TerminateProcess, and on Unix and Mac OS X, the SIGKILL signal is sent to the process.
On Symbian, this function requires platform security capabilityPowerMgmt. If absent, the process will panic with KERN-EXEC 46.
Note:Killing running processes from other processes will typically cause a panic in Symbian due to platform security.
See alsoSymbian Platform Security Requirements andterminate().
Returns the additional native command line arguments for the program.
Note:This function is available only on the Windows and Symbian platforms.
This function was introduced in Qt 4.7.
See alsosetNativeArguments().
Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned.
Returns the channel mode of theQProcess standard output and standard error channels.
This function was introduced in Qt 4.2.
See alsosetProcessChannelMode(),ProcessChannelMode, andsetReadChannel().
Returns the environment thatQProcess will use when starting a process, or an empty object if no environment has been set using setEnvironment() orsetProcessEnvironment(). If no environment has been set, the environment of the calling process will be used.
Note:The environment settings are ignored on Windows CE, as there is no concept of an environment.
This function was introduced in Qt 4.6.
See alsosetProcessEnvironment(),setEnvironment(), andQProcessEnvironment::isEmpty().
Regardless of the current read channel, this function returns all data available from the standard error of the process as aQByteArray.
See alsoreadyReadStandardError(),readAllStandardOutput(),readChannel(), andsetReadChannel().
Regardless of the current read channel, this function returns all data available from the standard output of the process as aQByteArray.
See alsoreadyReadStandardOutput(),readAllStandardError(),readChannel(), andsetReadChannel().
Returns the current read channel of theQProcess.
See alsosetReadChannel().
[virtual protected]qint64 QProcess::readData(char * data,qint64 maxlen)Reimplemented fromQIODevice::readData().
[signal]void QProcess::readyReadStandardError()This signal is emitted when the process has made new data available through its standard error channel (stderr). It is emitted regardless of the currentread channel.
See alsoreadAllStandardError() andreadChannel().
[signal]void QProcess::readyReadStandardOutput()This signal is emitted when the process has made new data available through its standard output channel (stdout). It is emitted regardless of the currentread channel.
See alsoreadAllStandardOutput() andreadChannel().
This is an overloaded function.
Sets additional native command linearguments for the program.
On operating systems where the system API for passing command linearguments to a subprocess natively uses a single string, one can conceive command lines which cannot be passed viaQProcess's portable list-based API. In such cases this function must be used to set a string which isappended to the string composed from the usual argument list, with a delimiting space.
Note:This function is available only on the Windows and Symbian platforms.
This function was introduced in Qt 4.7.
See alsonativeArguments().
Sets the channel mode of theQProcess standard output and standard error channels to themode specified. This mode will be used the next timestart() is called. For example:
QProcess builder;builder.setProcessChannelMode(QProcess::MergedChannels);builder.start("make",QStringList()<<"-j2");if (!builder.waitForFinished())qDebug()<<"Make failed:"<< builder.errorString();elseqDebug()<<"Make output:"<< builder.readAll();
This function was introduced in Qt 4.2.
See alsoprocessChannelMode(),ProcessChannelMode, andsetReadChannel().
Sets the environment thatQProcess will use when starting a process to theenvironment object.
For example, the following code adds theC:\\BIN directory to the list of executable paths (PATHS) on Windows and setsTMPDIR:
QProcess process;QProcessEnvironment env=QProcessEnvironment::systemEnvironment();env.insert("TMPDIR","C:\\MyApp\\temp");// Add an environment variableenv.insert("PATH", env.value("Path")+";C:\\Bin");process.setProcessEnvironment(env);process.start("myapp");
Note how, on Windows, environment variable names are case-insensitive.
This function was introduced in Qt 4.6.
See alsoprocessEnvironment(),QProcessEnvironment::systemEnvironment(), andsetEnvironment().
[protected]void QProcess::setProcessState(ProcessState state)Sets the current state of theQProcess to thestate specified.
See alsostate().
Sets the current read channel of theQProcess to the givenchannel. The current input channel is used by the functionsread(),readAll(),readLine(), andgetChar(). It also determines which channel triggersQProcess to emitreadyRead().
See alsoreadChannel().
Redirects the process' standard error to the filefileName. When the redirection is in place, the standard error read channel is closed: reading from it usingread() will always fail, as willreadAllStandardError(). The file will be appended to ifmode is Append, otherwise, it will be truncated.
SeesetStandardOutputFile() for more information on how the file is opened.
Note: ifsetProcessChannelMode() was called with an argument ofQProcess::MergedChannels, this function has no effect.
This function was introduced in Qt 4.2.
See alsosetStandardInputFile(),setStandardOutputFile(), andsetStandardOutputProcess().
Redirects the process' standard input to the file indicated byfileName. When an input redirection is in place, theQProcess object will be in read-only mode (callingwrite() will result in error).
If the filefileName does not exist at the momentstart() is called or is not readable, starting the process will fail.
Calling setStandardInputFile() after the process has started has no effect.
This function was introduced in Qt 4.2.
See alsosetStandardOutputFile(),setStandardErrorFile(), andsetStandardOutputProcess().
Redirects the process' standard output to the filefileName. When the redirection is in place, the standard output read channel is closed: reading from it usingread() will always fail, as willreadAllStandardOutput().
If the filefileName doesn't exist at the momentstart() is called, it will be created. If it cannot be created, the starting will fail.
If the file exists andmode isQIODevice::Truncate, the file will be truncated. Otherwise (ifmode isQIODevice::Append), the file will be appended to.
Calling setStandardOutputFile() after the process has started has no effect.
This function was introduced in Qt 4.2.
See alsosetStandardInputFile(),setStandardErrorFile(), andsetStandardOutputProcess().
Pipes the standard output stream of this process to thedestination process' standard input.
The following shell command:
command1| command2Can be accomplished with QProcesses with the following code:
QProcess process1;QProcess process2;process1.setStandardOutputProcess(&process2);process1.start("command1");process2.start("command2");
This function was introduced in Qt 4.2.
Sets the working directory todir.QProcess will start the process in this directory. The default behavior is to start the process in the working directory of the calling process.
Note:The working directory setting is ignored on Symbian; the private directory of the process is considered its working directory.
Note:On QNX, this may cause all application threads to temporarily freeze.
See alsoworkingDirectory() andstart().
[virtual protected]void QProcess::setupChildProcess()This function is called in the child process context just before the program is executed on Unix or Mac OS X (i.e., afterfork(), but beforeexecve()). Reimplement this function to do last minute initialization of the child process. Example:
class SandboxProcess :publicQProcess{...protected:void setupChildProcess();...};void SandboxProcess::setupChildProcess(){// Drop all privileges in the child process, and enter// a chroot jail.#if defined Q_OS_UNIX::setgroups(0,0);::chroot("/etc/safe");::chdir("/");::setgid(safeGid);::setuid(safeUid);::umask(0);#endif}
You cannot exit the process (by calling exit(), for instance) from this function. If you need to stop the program before it starts execution, your workaround is to emitfinished() and then call exit().
Warning: This function is called byQProcess on Unix and Mac OS X only. On Windows and QNX, it is not called.
Starts the givenprogram in a new process, if none is already running, passing the command line arguments inarguments. TheOpenMode is set tomode.
TheQProcess object will immediately enter the Starting state. If the process starts successfully,QProcess will emitstarted(); otherwise,error() will be emitted. If theQProcess object is already running a process, a warning may be printed at the console, and the existing process will continue running.
Note:Processes are started asynchronously, which means thestarted() anderror() signals may be delayed. CallwaitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted.
Note:No further splitting of the arguments is performed.
Windows: Arguments that contain spaces are wrapped in quotes.
See alsopid(),started(), andwaitForStarted().
This is an overloaded function.
Starts the programprogram in a new process, if one is not already running.program 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");...
Theprogram string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process. For example:
QProcess process;process.start("dir \"My Documents\"");
If theQProcess object is already running a process, a warning may be printed at the console, and the existing process will continue running.
Note that, on Windows, quotes need to be both escaped and quoted. For example, the above code would be specified in the following way to ensure that"My Documents" is used as the argument to thedir executable:
QProcess process;process.start("dir \"\"\"My Documents\"\"\"");
TheOpenMode is set tomode.
[static]bool QProcess::startDetached(constQString & program, constQStringList & arguments, constQString & workingDirectory,qint64 * pid = 0)Starts the programprogram with the argumentsarguments in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to live.
Note that arguments that contain spaces are not passed to the process as separate arguments.
Unix: The started process will run in its own session and act like a daemon.
Windows: Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process.
The process will be started in the directoryworkingDirectory.
Note:On QNX, this may cause all application threads to temporarily freeze.
If the function is successful then *pid is set to the process identifier of the started process.
[static]bool QProcess::startDetached(constQString & program, constQStringList & arguments)Starts the programprogram with the givenarguments in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to live.
Note:Arguments that contain spaces are not passed to the process as separate arguments.
Unix: The started process will run in its own session and act like a daemon.
Windows: Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process.
[static]bool QProcess::startDetached(constQString & program)This is an overloaded function.
Starts the programprogram in a new process.program is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces.
Theprogram string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process.
[signal]void QProcess::started()This signal is emitted byQProcess when the process has started, andstate() returnsRunning.
Returns the current state of the process.
See alsostateChanged() anderror().
[signal]void QProcess::stateChanged(QProcess::ProcessState newState)This signal is emitted whenever the state ofQProcess changes. ThenewState argument is the stateQProcess changed to.
[static]QStringList QProcess::systemEnvironment()Returns the environment of the calling process as a list of key=value pairs. Example:
QStringList environment=QProcess::systemEnvironment();// environment = {"PATH=/usr/bin:/usr/local/bin",// "USER=greg", "HOME=/home/greg"}
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 otputenv have been called.
However, note that repeated calls to this function will recreate the list of environment variables, which is a non-trivial operation.
Note:For new code, it is recommended to useQProcessEnvironment::systemEnvironment()
This function was introduced in Qt 4.1.
See alsoQProcessEnvironment::systemEnvironment(),environment(), andsetEnvironment().
[slot]void QProcess::terminate()Attempts to terminate the process.
The process may not exit as a result of calling this function (it is given the chance to prompt the user for any unsaved files, etc).
On Windows, terminate() posts a WM_CLOSE message to all toplevel windows of the process and then to the main thread of the process itself. On Unix and Mac OS X the SIGTERM signal is sent.
Console applications on Windows that do not run an event loop, or whose event loop does not handle the WM_CLOSE message, can only be terminated by callingkill().
On Symbian, this function requires platform security capabilityPowerMgmt. If absent, the process will panic with KERN-EXEC 46.
Note:Terminating running processes from other processes will typically cause a panic in Symbian due to platform security.
See alsoSymbian Platform Security Requirements andkill().
[virtual]bool QProcess::waitForBytesWritten(int msecs = 30000)Reimplemented fromQIODevice::waitForBytesWritten().
Blocks until the process has finished and thefinished() signal has been emitted, or untilmsecs milliseconds have passed.
Returns true if the process finished; otherwise returns false (if the operation timed out, if an error occurred, or if thisQProcess is already finished).
This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.
Warning: Calling this function from the main (GUI) thread might cause your user interface to freeze.
If msecs is -1, this function will not time out.
See alsofinished(),waitForStarted(),waitForReadyRead(), andwaitForBytesWritten().
[virtual]bool QProcess::waitForReadyRead(int msecs = 30000)Reimplemented fromQIODevice::waitForReadyRead().
Blocks until the process has started and thestarted() signal has been emitted, or untilmsecs milliseconds have passed.
Returns true if the process was started successfully; otherwise returns false (if the operation timed out or if an error occurred).
This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.
Warning: Calling this function from the main (GUI) thread might cause your user interface to freeze.
If msecs is -1, this function will not time out.
See alsostarted(),waitForReadyRead(),waitForBytesWritten(), andwaitForFinished().
IfQProcess has been assigned a working directory, this function returns the working directory that theQProcess will enter before the program has started. Otherwise, (i.e., no directory has been assigned,) an empty string is returned, andQProcess will use the application's current working directory instead.
See alsosetWorkingDirectory().
[virtual protected]qint64 QProcess::writeData(constchar * data,qint64 len)Reimplemented fromQIODevice::writeData().
Typedef for the identifiers used to represent processes on the underlying platform. On Unix and Symbian, this corresponds toqint64; on Windows, it corresponds to_PROCESS_INFORMATION*.
See alsoQProcess::pid().
© 2016 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 theGNU 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.