Tag: qt5

Qt 5和QProcess使用signal / slot readyRead重定向stdout

这个问题困扰我,因为它应该工作,但遗憾的是它没有。 我试图实现的是读取某个过程的标准输出并使另一个过程处理它,即将其打印出来。 生成输出的过程如下所示: #include #include #include int main() { for (int i = 0; i < 100; i++) { printf("yes %d\n",i); fflush(stdout); sleep(1); } return 0; } 该过程在另一个应用程序中启动,如下所示: #include … QProcess * process = new QProcess; SomeClass * someClass = new SomeClass(process); connect(process,SIGNAL(readyRead()),someClass,SLOT(onReadyRead())); process->start(“../Test/Test”,QStringList()); if (!process->waitForStarted(4000)) { qDebug() << "Process did not start."; } … […]