qt_gotcha
10th August 2010, 07:06
Hi,
I am rewriting my application from Borland to Qt. It calls an exe and pipes the output to the app. Originally I used CreateProcess, PeekNamedPipe etc. but these are native to windows and not multiplatform. I want to use QProcess and do not get very far. My simple code:
calcProcess = new QProcess(this);
connect(calcProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()) );
and in readFromStdout():
QString output;
output = calcProcess->readAllStandardOutput();
outputedit->appendPlainText(output); //outputedit is a PlainTextEdit
This seems to fill an output buffer (4096 bytes?) and the output is appended when the output buffer is full. I would then have to parse the output breaking it into strings with split or something.
I have read that the signal is triggered each time the external exe produces something, and I want to read this output each time (per line). I have looked at many pieces of code in the forum but can't find how to do this. Thanks.
I am rewriting my application from Borland to Qt. It calls an exe and pipes the output to the app. Originally I used CreateProcess, PeekNamedPipe etc. but these are native to windows and not multiplatform. I want to use QProcess and do not get very far. My simple code:
calcProcess = new QProcess(this);
connect(calcProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()) );
and in readFromStdout():
QString output;
output = calcProcess->readAllStandardOutput();
outputedit->appendPlainText(output); //outputedit is a PlainTextEdit
This seems to fill an output buffer (4096 bytes?) and the output is appended when the output buffer is full. I would then have to parse the output breaking it into strings with split or something.
I have read that the signal is triggered each time the external exe produces something, and I want to read this output each time (per line). I have looked at many pieces of code in the forum but can't find how to do this. Thanks.