[Qt-interest] Problem with sending binary data to stdin of QProcess child. There's no QProcess::flush

Bart van Deenen bvandeenen at infologic.nl
Mon Jan 12 09:00:20 CET 2009


On Mon, 2009-01-12 at 08:36 +0100, Thiago Macieira wrote:
> Bart van Deenen wrote:
> >#include <QtCore/QCoreApplication>
> >#include <QProcess>
> >int main(int argc, char *argv[]) {
> >
> >QCoreApplication a(argc, argv);
> >QProcess process;
> >process.flush();
> >return a.exec();
> >}
> 
> You want waitForBytesWritten().

Ok thanks

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




More information about the Qt-interest-old mailing list