I was wondering if there is a way to use QProcess
to start the main.cpp of another class to enter into its execution as such
QProcess *myProcessA = new QProcess();
myProcessA->start("*Anotherclass*main.cpp");
I can start applications and other executable arguments via QProcess
, but the reason is I am integrating an external application (not written in C++) into a widget in Qt.
I can launch the external app via QProcess
fine, but to embed it I need to launch it in another main thread that would hold the process I already created and sync them.
Sounds confusing but please my question is just plain and simple:
QProcess *myProcessA = new QProcess();
myProcessA->start("*Anotherclass*main.cpp");
Or better still, how to set an argument/path to run a class file using QProcess
?
You cannot run C++ source code using QProcess
, in a similar way that you cannot run it from a shell or file explorer. You must compile it first to create a separate program. Once compiled, launch the executable created using QProcess
similarly as how you've been doing:
QProcess *myProcessA = new QProcess();
myProcessA->start("the_exec.exe"); // extension assuming Windows
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.