I found similar questions, but did not answer for sure. I have a Qt program that launches QProcess and writes the output to the QTextEdit field, as far as it is good. But this only happens when the program has ended. if possible, I would like stdout to print in real time. In an ideal world, there will be some kind of signal that QProcess emits when there is a line ready to read, if this is not possible with QProcess, is it possible at all? Ideally, you can still use the rest of the program while you work.
Here is the code I still have, very simple, it just emits the first line of stdout QProcess in QTextEdit
... extProcess::extProcess(QObject *parent) : QObject(parent) extProcess::extProcess(QObject *parent) : QObject(parent) { proc = new QProcess(this);
This is an alternative version that I tried, it will show all the QProcess output, but still only show it when the program ends.
... extProcess::extProcess(QObject *parent) : QObject(parent) { proc = new QProcess(this); //initialize proc proc->setProcessChannelMode(QProcess::SeparateChannels); arguments << "-v"; connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(logReady())); } void extProcess::logReady() { while(proc->bytesAvailable()){ emit outLog(proc->readLine()); } } void extProcess::startProcess() { emit clearLog(); emit outLog("--Process started--"); proc->start("/Users/jonathan/Desktop/testgg"); } void extProcess::killProcess() { proc->terminate(); emit clearLog(); emit outLog("--Process Terminated--"); } ....
thanks
source share