PDA

View Full Version : why did readyreadstandardoutput signal not work?



sunnysun520
29th July 2009, 08:40
hello,everybody.
I use Qprocess to connect my c program ,but the signal readyreadstandardoutput can not connect to my slot function?
why?I channge the signal to readyreadstandardError,is works,why?

Ginsengelf
29th July 2009, 09:23
Hi, does your connect() call fail, or do you just get no data with readyReadStandardOutput?
In the second case, your c program probably writes to stderr, not to stdout.

Ginsengelf

wagmare
29th July 2009, 09:35
because QProcess have two seperate channels to read normal output and error

It also emits readyReadStandardOutput() when new standard output data is available, and when new standard error data is available, readyReadStandardError() is emitted

if u want a single output use
setProcessChannelMode(QProcess::MergedChannels);

sunnysun520
30th July 2009, 03:52
Hi, does your connect() call fail, or do you just get no data with readyReadStandardOutput?
In the second case, your c program probably writes to stderr, not to stdout.

Ginsengelf

hi ,I think it failed, because I "cout something" in the slot function,it did not display int the console .

sunnysun520
30th July 2009, 03:57
because QProcess have two seperate channels to read normal output and error


if u want a single output use
setProcessChannelMode(QProcess::MergedChannels);

I will try

sunnysun520
30th July 2009, 11:45
because QProcess have two seperate channels to read normal output and error


if u want a single output use
setProcessChannelMode(QProcess::MergedChannels);

the following is some of my src code.

connect(&process,SIGNAL(readyReadStandardOutput()),this,SLO T(updaterev_line()));
。。。。。
process.setProcessChannelMode(QProcess::SeparateCh annels);
process.setReadChannel(QProcess::StandardOutput);

it does not work too!(the signal can not connect the solt func!)

wagmare
30th July 2009, 12:16
process.setProcessChannelMode(QProcess::SeparateCh annels)
process.setReadChannel(QProcess::StandardOutput);

no need to set this one .. it is default ...

look u will receive readyReadStandardOutput() only when your external application that u are starting using QProcess should have stdOutput() .. if it is giving stdErr() then u cant receive readyReadStandardOutput() ..

only way to receive stdErr() in readyReadStandardOutput() .. merge the two channels ..

QProcess merges the output of the running process into the standard output channel (stdout). The standard error channel (stderr) will not receive any data. The standard output and standard error data of the running process are interleaved.