Unsolved how to pipe qprocess' stdout to father process as stdin
-
@JNBarchan I found a workaround.
Now I usingQProcess
'sstartDetached()
likeQProcess* restart; restart = new QProcess; restart->startDetached("bash -c \"streamlink -O | my-qt-program \""); exit(0);
It works well!
-
@Isolde
Yes, you mean, you have written that as a second Qt application which does this to invoke your original Qt application, instead of a script file. Which is what we were suggesting :) [EDIT: Or, do you mean you actually do this from within your original "my-qt-program"?] -
@JNBarchan said in how to pipe qprocess' stdout to father process as stdin:
Or, do you mean you actually do this from within your original "my-qt-program
That would be an endless loop :-)
-
@JNBarchan said in how to pipe qprocess' stdout to father process as stdin:
is
Not quite. I just add a simple if statement that determine whether to execute this restart code like
if(QCoreApplication::arguments().at(1) != "bypass-parser") { QProcess* restart; restart = new QProcess; restart->startDetached("bash -c \"streamlink " + parser.value(urlOption) + " " + parser.value(streamOption) + " -O | " + QCoreApplication::applicationFilePath() + " bypass-parser " + parser.value(urlOption) + "\""); exit(0); }
-
@jsulm I'm sorry. They are not the whole codes, I post them completely in the last reply.
-
@Isolde You should not exit a Qt app like this, use http://doc.qt.io/qt-5/qcoreapplication.html#exit instead. Also there is no need to allocate QProcess on the heap. And in this particular case there is even no need for a QProcess instance at all as startDetached is static:
if(QCoreApplication::arguments().at(1) != "bypass-parser") { QProcess::startDetached("bash -c \"streamlink " + parser.value(urlOption) + " " + parser.value(streamOption) + " -O | " + QCoreApplication::applicationFilePath() + " bypass-parser " + parser.value(urlOption) + "\""); QCoreApplication::exit(0); }
-
@jsulm Got it. I'll amend it. Thank you very much.
-
@jsulm said in how to pipe qprocess' stdout to father process as stdin:
@JNBarchan said in how to pipe qprocess' stdout to father process as stdin:
Or, do you mean you actually do this from within your original "my-qt-program
That would be an endless loop :-)
That's why I asked, and he has posted to show how he detects....
-
@jsulm said in how to pipe qprocess' stdout to father process as stdin:
@Isolde You should not exit a Qt app like this, use http://doc.qt.io/qt-5/qcoreapplication.html#exit instead. Also there is no need to allocate QProcess on the heap. And in this particular case there is even no need for a QProcess instance at all as startDetached is static:
if(QCoreApplication::arguments().at(1) != "bypass-parser") { QProcess::startDetached("bash -c \"streamlink " + parser.value(urlOption) + " " + parser.value(streamOption) + " -O | " + QCoreApplication::applicationFilePath() + " bypass-parser " + parser.value(urlOption) + "\""); QCoreApplication::exit(0); }
There is a strange problem, my program won't exit with
QCoreApplication::exit(0);
(but it could exit normally withexit(0)
), I saw two windows withQCoreApplication::exit(0);
. And the terminal output indicated that the old process had run into the GUI drawing step. -
So you want to control mpv from your application ?