[Qt-interest] Problem with sending binary data to stdin of?QProcess child.
Andreas Pakulat
apaku at gmx.de
Sun Jan 11 19:59:44 CET 2009
On 11.01.09 19:36:10, Bart van Deenen wrote:
> 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.
QProcess is a QIODevice, so you can just call flush() on your process,
that should work.
Andreas
--
You may get an opportunity for advancement today. Watch it!
More information about the Qt-interest-old
mailing list