QProcess
A Qt class that launches and manages external processes from within your application, used wherever you would use fork/exec in plain C++. It handles starting the process, managing its input/output streams, waiting for it to finish, and inspecting the result. It is preferred over raw fork/exec in Qt codebases because it cooperates with Qt's own internal signal handling. QProcess::nullDevice()
A static method on QProcess that returns the path to the null device (/dev/null on Linux), which discards anything written to it and returns nothing when read. It is used to silence stdin and stdout when you only care about stderr. Being a static method it is called on the class itself rather than an instance. QProcess::FailedToStart
An error code on QProcess that indicates the executable could not be launched at all, typically because it was not found on the system's PATH or the user lacks permission to run it. It is checked via process.error() after waitForFinished() returns false to distinguish between a launch failure and a timeout. Being a static value it is referenced on the class itself rather than an instance. QProcess::NormalExit
A status code on QProcess that indicates the process exited cleanly on its own, as opposed to being killed by a signal or crashing. It is checked via process.exitStatus() after waitForFinished() returns to confirm the process shut down normally before trusting the exit code. Being a static value it is referenced on the class itself rather than an instance. QProcess::NotRunning
A value of the QProcess::ProcessState enum indicating the process is not currently running — either it hasn't started yet or it has already finished. Check it via .state() to detect that a process exited between polling slices. |
Cheatography
https://cheatography.com
C++ (QProcess) Cheat Sheet (DRAFT) by blakecromar
A cheatsheet on the C++ QProcess framework
This is a draft cheat sheet. It is a work in progress and is not finished yet.