QProcess, readyRead, QTextEdit
I want to be able to 'continuously' append the output of a command-line into a QTextEdit.
I have a GUI app that uses QProcess to start a command-line app. The CL app has tons of output via printf's.
I am current connecting to the readyRead() signal of the QProcess and using readAllStandardOutput() to post the info into the QTextEdit. The problem with this is that I only get the output once the CL app is finished.
What do I need to do to get the output as it happens?
TIA, Sam.
Re: QProcess, readyRead, QTextEdit
what happens if you use the readyReadStandardOutput () signal instead?
Re: QProcess, readyRead, QTextEdit
Quote:
The CL app has tons of output via printf's
Is it your command line application ? If yes, you may consider flushing the stdout after printf:
Code:
printf("A text");
fflush(stdout);
stdout is buffered, but it should flush automatically after reaching new line character.
Also try to set read channel for QProcess:
Code:
proc
->setReadChannel
(QProcess::StandardOutput);
Re: QProcess, readyRead, QTextEdit
Got it working better...
printf and fflush and QProcess::StandardOutput and readyReadStandardOutput () did the trick.
Re: QProcess, readyRead, QTextEdit
Quote:
printf and fflush (...)
I think you can even disable buffering of the stdout in your app:
Code:
setbuf(stdout,NULL);