-1

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?

cbuchart
  • 10,847
  • 9
  • 53
  • 93
OlaB
  • 176
  • 11

1 Answers1

3

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
cbuchart
  • 10,847
  • 9
  • 53
  • 93