View Full Version : speed up qprocess readstdout

30th January 2006, 22:48
im making a qprocess running a program and i have a textfield that prints the output of the program.

im using the folloiwn code to get the output

void mainForm::readFromStdout()
outputTextEdit->append( proc->readStdout() );


connect( proc, SIGNAL(readyReadStdout()),
this, SLOT(readFromStdout()) );

everything works fine. except the only problem is, this output reads in chunks, rather than smoothly.

even in the example from qt3 for qprocess it says

void UicManager::readFromStdout()
// Read and process the data.
// Bear in mind that the data might be output in chunks.
output->append( proc->readStdout() );

i think it has to do with the buffer size set in qprocess->readStdout(). im not sure how to change this. is there anyway to i can make the output append more frequently?

31st January 2006, 10:42
You'd have to change the buffer of the pipe between your application and the external process, but it would slow down both apps and the operating system itself. If you want smooth output, store the data from external process instead of appending it to the text field directly and use a timer to fetch the data from your storage and feed it to the text box.

You might also want to take a look at QProcess::canReadLineStdout() and QProcess:readLineStdout() to read data line by line.