PDA

View Full Version : pipe in a QByteArray to a QProcess



Gravis
28th February 2010, 06:52
I have an QByteArray with binary data. I want to "pipe" it into a new QProcess, so the process takes it as stdin.

I'm really just stuck with this and could really use the help. :confused:

btw, writing to a temp file isnt acceptable because this is going to be done millions of times as this is a database related app.

ChrisW67
28th February 2010, 22:53
As a QIODevice, QProcess inherits a method to write a QByteArray to the process:
QIODevice::write(const QByteArray & byteArray ) (http://doc.trolltech.com/latest/qiodevice.html#write)

You should be able to just write to the QProcess instance and then, depending on the needs of the process, call void QProcess::closeWriteChannel ().

If you are going to do this millions of times then you probably want a single, persistent sub-process or you'll have millions of process startup delays.