Unsolved Running external Python 3 script
I want to run an external .py script that I made. I have tested the script in VS and it runs fine. When I try to implement it in QT, it will not open. Here is what I have in my .cpp file:
QString path = "C:/../python.exe"; QString command("python"); QStringList params = QStringList() << "C:/../test.py"; QProcess *process = new QProcess(); process->startDetached(command, params, path); process->waitForFinished(); process->close();
I do not get any errors when pressing the button, in fact, I get nothing from the output. Any ideas?
JonB last edited by
What do you mean by "it will not open."? "I get nothing from the output." what output? Why are you using
QProcess::startDetached()to run your script? How do you know it does not run?
If you want know know exactly what is going on, you should not call startDetached.
Start your QProcess normally and check the it starts correctly and for errors.
How would that look? I am a little lost figuring out the Qprocess
You have an example in the Synchronous Process API part of QProcess's documentation.
You have the error method.
JonB last edited by JonB
You will need to look at the links @SGaist has given you and implement. But first things first: have you replaced
start(), does that behave differently for you? Or you might find the static https://doc.qt.io/qt-5/qprocess.html#execute a simpler place to start out from: its return code at least tells you what happened when invoking the process, before you proceed to pick up the output. The problem is you still have not explained what you mean by "I get nothing from the output." Does your script send output to stdout which you see when you run it elsewhere (e.g. a terminal) and you want to capture that out in your Qt program?
@saltywaffles which Qt version are you using?