currently I start another program via QProcess and connect the read readyReadStandardOutput to a slot:
QProcess *start = new QProcess(this);
start->start(program,arguments);
connect(start, SIGNAL(readyReadStandardOutput()), log, SLOT(readyReadStandardOutput()));
connect(start, SIGNAL(readyReadStandardError()), log, SLOT(readyReadStandardError()));
log is of type myTextBrowser
class myTextBrowser : public QTextBrowser{
...
public slots:
void readyReadStandardOutput();
void readyReadStandardError();
...
}
the slots look something like this:
void myTextBrowser::readyReadStandardOutput(){
QProcess *p = qobject_cast<QProcess*>(sender());
QString txt (p->readAllStandardOutput());
...
setText(txt);
}
The problem is, that there is a big latency. The text in my GUI only gets updated every couple of seconds, sometimes even close to a minute.
Is there a more elegant solution to forward the output to another widget?
Please note that the called program could run for a hour but the displayed output is not very long... But it is not possible to waitForFinished
because I want that the GUI is still usable while the process runs.