#include#include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QProcess process; process.start("python", QStringList() << "--version"); if(process.waitForFinished()) { QString output(process.readAllStandardOutput()); qDebug() << output; } return a.exec(); }
#includeThis code starts a new process with the "ls" command which lists the files in the current directory. It then waits for the process to finish and reads the output from its standard output channel. Finally, it prints the output to the console. The package library used in this example is Qt5Core. In both examples, the package library used is Qt5Core which is a part of the Qt framework.#include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QProcess process; process.start("ls"); if(process.waitForFinished()) { QString output(process.readAllStandardOutput()); qDebug() << output; } return a.exec(); }