How to send INPUT & receive OUTPUT : Calling Python from C++:
-
wrote on 28 Jul 2020, 02:42 last edited by
Greetings,
I am executing the following code to call python script from c++ using QProcess.
QString path = "C:/pythonCPP"; QString command("python"); QStringList params = QStringList() << "pyemb3.py"; QProcess *process = new QProcess(); process->startDetached(command, params, path); process->waitForFinished(); process->close();
My question is how can I provide input parameters to and receive the output of python script being called.
I've skimmed through different forums/references/portals but couldn't get an understandable answer.
Looking forward to your kind responses.
Best Regards,
Ahsan -
Greetings,
I am executing the following code to call python script from c++ using QProcess.
QString path = "C:/pythonCPP"; QString command("python"); QStringList params = QStringList() << "pyemb3.py"; QProcess *process = new QProcess(); process->startDetached(command, params, path); process->waitForFinished(); process->close();
My question is how can I provide input parameters to and receive the output of python script being called.
I've skimmed through different forums/references/portals but couldn't get an understandable answer.
Looking forward to your kind responses.
Best Regards,
Ahsan@ahsan737 https://doc.qt.io/qt-5/qprocess.html "Communicating via Channels"
Don't use startDetached() and don't call waitForFinished().
1/2