Qt-interest Archive, April 2007
Issue with QProcess 'readyReadStandardOutput' signal
Message 1 in thread
Hi,
I have a process that sends data not 'totally' at once.
in QT3, I could trigger the 'readyReadStdout()' signal and then do :
while (programProcess->canReadLineStdout())
buff=append(programProcess->readLineStdout());
and I got all my data all right
Now, with QT4, I use 'readyReadStandardOutput()'
But since there is no 'canRead...' function, I have trouble because each
time a character is sent, it triggers the reading slot, and I can't get the
whole output.
Any idea as how I could do this ?
--
[ signature omitted ]
Message 2 in thread
On 20.04.07 22:34:01, eb wrote:
> I have a process that sends data not 'totally' at once.
>
> in QT3, I could trigger the 'readyReadStdout()' signal and then do :
>
> while (programProcess->canReadLineStdout())
> buff=append(programProcess->readLineStdout());
>
> and I got all my data all right
>
>
> Now, with QT4, I use 'readyReadStandardOutput()'
> But since there is no 'canRead...' function, I have trouble because each
> time a character is sent, it triggers the reading slot, and I can't get the
> whole output.
>
> Any idea as how I could do this ?
Just read what is there on stdout and store it into your buffer.
Something like: buff=append(programProcess->readAllStandardOutput());
Andreas
--
[ signature omitted ]
Message 3 in thread
Andreas Pakulat wrote:
> On 20.04.07 22:34:01, eb wrote:
>> I have a process that sends data not 'totally' at once.
>>
>> in QT3, I could trigger the 'readyReadStdout()' signal and then do :
>>
>> while (programProcess->canReadLineStdout())
>> buff=append(programProcess->readLineStdout());
>>
>> and I got all my data all right
>>
>>
>> Now, with QT4, I use 'readyReadStandardOutput()'
>> But since there is no 'canRead...' function, I have trouble because each
>> time a character is sent, it triggers the reading slot, and I can't get
>> the whole output.
>>
>> Any idea as how I could do this ?
>
> Just read what is there on stdout and store it into your buffer.
>
> Something like: buff=append(programProcess->readAllStandardOutput());
>
> Andreas
>
Well, precisely, it does not work because it gets 1 character.
Then the slot is triggered again, and it get 1 char, etc ...
But I havee found an idea in the doc, with the waitForReadyRead not being
recursive.
--
[ signature omitted ]
Message 4 in thread
On 20.04.07 23:21:39, eb wrote:
> Andreas Pakulat wrote:
>
> > On 20.04.07 22:34:01, eb wrote:
> >> I have a process that sends data not 'totally' at once.
> >>
> >> in QT3, I could trigger the 'readyReadStdout()' signal and then do :
> >>
> >> while (programProcess->canReadLineStdout())
> >> buff=append(programProcess->readLineStdout());
> >>
> >> and I got all my data all right
> >>
> >>
> >> Now, with QT4, I use 'readyReadStandardOutput()'
> >> But since there is no 'canRead...' function, I have trouble because each
> >> time a character is sent, it triggers the reading slot, and I can't get
> >> the whole output.
> >>
> >> Any idea as how I could do this ?
> >
> > Just read what is there on stdout and store it into your buffer.
> >
> > Something like: buff=append(programProcess->readAllStandardOutput());
> >
> Well, precisely, it does not work because it gets 1 character.
> Then the slot is triggered again, and it get 1 char, etc ...
Huh? What does not work? The code above should fill your buffer one
character after another, if buff is a member variable and not a
function-local. If that doesn't work, please post some more code.
> But I havee found an idea in the doc, with the waitForReadyRead not being
> recursive.
So you actually want to not have the process run in the background but
block your Ui until the process finished?
Andreas
--
[ signature omitted ]