[Qt-interest] Problem with sending binary data to stdin of QProcess child.
Bart van Deenen
bvandeenen at infologic.nl
Sun Jan 11 19:36:10 CET 2009
On Sunday 11 January 2009 16:12:57 Andreas Pakulat wrote:
> On 10.01.09 13:16:27, Bart van Deenen wrote:
> > I'm stuck with getting data from the parent process to the child process
> > though, and I don't see where I'm going wrong.
> > qint64 ct = process.write(s.data(), s.length());
> > the std::string s is a google protocol buffer encoded string, i.e.
> > binary blobs. The current test message has a length of 2 bytes, and I
> > always receive the message "Wrote 2 bytes to child process" so that goes
> > well.
> >
> > On the child receiver side I have a QThread, that should handle the
> > commands on stdin,
> > but It always tells me that there is no data available. ('debug' is a
> > member QFile * for debugging purposes). I've also tried f.open(stdin,...)
> > and std::cin and you name it.
> Well, you're not closing or flushing stdin of the process, so the data
> might still be in some buffer (Qt or native). So if you don't need stdin
> anymore, just close it on the sender side. Else at least flush it after
> you've written your chunk of data.
But how??
There is no flush() for QProcess, even though QIODevice defines a flush.
I think you're right, but I can't find the way how.
My plan is to keep the stdio pipes open, because I'll have more
commands at another moment.
If I can't get some kind of flush working, I'll switch to QLocalSocket and
do it that way.
Thanks
Bart
More information about the Qt-interest-old
mailing list