QProcess *myProcess = new QProcess(this); myProcess->start("ls"); // Starts the 'ls' command myProcess->waitForFinished(); // Waits for the process to finish myProcess->deleteLater(); // Deletes the QProcess object after it has finished
void MyClass::startProcess() { QProcess *myProcess = new QProcess(this); myProcess->start("echo", QStringList() << "Hello World"); connect(myProcess, SIGNAL(finished(int, QProcess::ExitStatus)), myProcess, SLOT(deleteLater())); }This example shows how to start an external process to echo "Hello World", and connect the finished signal to the deleteLater slot to ensure that the QProcess object is deleted when the process is finished. Package/Library: This class is part of the Qt Core module, which is part of the Qt library.