[Qt-interest] Problem with sending binary data to stdin of QProcess child. There's no QProcess::flush
Scott Aron Bloom
Scott.Bloom at sabgroup.com
Mon Jan 12 10:14:58 CET 2009
> I've done that, and it seems that the sending side is fine. I'm still
> getting nothing on the receiving side though :-(
> This is the code on the receiving side.
>
> QFile f;
> f.open(stdin, QFile::ReadOnly | QIODevice::Unbuffered);
>
> while(true) {
> std::cerr << "HERE while!" << std::endl;
> if (bytesavailable == 0 ) {
> qint64 bytesavailable = f.bytesAvailable();
> usleep(1000000);
> std::cerr << "no bytes available"<<std::endl;
> continue;
> }
>
> QByteArray bytes = f.read(bytesavailable);
> std::cerr << "after read!" << bytesavailable << std::endl;
> ...
> }
>
> Why oh why? Could it be the contents of my two bytes? { 0x0A, 0x00 }
>
> Thanks
>
> Bart
So what happens if you change tohe loop to be...
While ( true )
{
if ( !f.waitForReadyRead( 1000000 ) )
continue;
QByteArray bytes = f.read( f.bytesAvailable() );
.....
}
Your bytes available value appears to be local to the wrong scope... I
don't know it could be an email bug :)
Scott
More information about the Qt-interest-old
mailing list