[SOLVED] How to send Standard input to a QProcess or use piping
Is it possible to send standard input to a QProcess? like piping in GNU/Linux.
I ran mplayer2 using:
QProcess *process = new QProcess(); process->start("mplayer2 input.mp4");
mplayer2 could be controlled using standard input. For instance, when i presss f key in command line, it makes it full screen. how can i send a key to the process?
I tried these but without any success:
QProcess *parentProcess = new QProcess(); parentProcess->setProgram("echo f"); QProcess *childProcess = new QProcess(parentProcess); childProcess->setInputChannelMode( QProcess::ForwardedInputChannel ); childProcess->start(); . . . parentProcess->start("echo f");
QProcess::ManagedInputChannel : QProcess manages the input of the running process. This is the default input channel mode of QProcess.
QProcess::ForwardedInputChannel : QProcess forwards the input of the main process onto the running process. The child process reads its standard input from the same source as the main process. Note that the main process must not try to read its standard input while the child process is running.
Might work with
Thanks. It solved the problem. Actually i used the following code:
mplayerProcess->start("mplayer2 --slave --quiet input.mp4"); ... QByteArray command("pause 1\n"); mplayerProcess->write( command );