I am trying to run a script in parallel to my Qt program and am having trouble starting it as a separate process. Check out my attempts below and let me know what you see wrong.
The first attempt was just a system call:
system("python3 startprocess.py");
This works but it also stops the program while running it.
I then followed this guy https://forum.qt.io/topic/92205/writing-commands-to-linux-bash with no success. No errors, just no start of my script.
I am trying this after I saw the documentation and have the below code.
QProcess process;
process.start("python3 startprocess.py");
process.waitForStarted();
I am just wanting to start this script and have it run at the same time as my C++ code. Perhaps I am using the QProcess wrong?
UPDATE: It was a lot easier to use QThreading and the original system call.
QProcesswithout trouble: 1. Avoid all the waitForXxx methods (they cause event loop to be re-entered, which can lead to issues in complex applications, which means all GUI applications). 2. Connect all the signals ofQProcess, at least to a lambda withqDebugprint, so you will notice when things don't work the way you expect. 3. Pass the parameters asQStringListto avoid surprises with splitting at spaces.