[SOLVED] How to send Standard input to a QProcess or use piping
-
hi folks
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");
from documentation:
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. -
Hi
Might work with
process->write("f\n") ;https://forum.qt.io/topic/52957/solved-qprocess-run-external-cmd-exe-with-interactive-input/6