#include#include int main() { QProcess process; process.start("echo Hello World"); if (process.waitForStarted() && process.waitForReadyRead()) { qDebug() << process.readAllStandardOutput(); } return 0; }
#includeIn this example, we spawn an external process that continuously sends data to the standard output stream (pinging google.com). We then use a QTimer to periodically check if data is available in the stream using the waitForReadyRead function. Once data is available, we print it out to the console using the qDebug function. Package/library: The QProcess class is part of the Qt framework, which is a C++ application development framework.#include #include int main() { QProcess process; process.start("ping google.com"); QTimer timer; timer.start(1000); QObject::connect(&timer, &QTimer::timeout, [&]() { if (process.waitForReadyRead()) { qDebug() << process.readAllStandardOutput(); } }); return 0; }