Maxx
Maxx

Reputation: 602

C++ Qt Run parts of an Application in separate process

I'm facing this issue of how to run different parts of an Application in separate process as the member function for QProcess that sets a process name requires a full path.

void setProgram(const QString &program)

But the process i'm trying to run is basically a module of the Main Application. So let me explain what i'm trying to achieve basically.

The application has QMainWindow as the central window which will controls all the different modules, monitor them, stop/restart them, communicate with them via IPC mechanism.

  1. So for example one of the modules has a QWebEngineView that will direct the user to a certain website and manage session information( cookies, authentications, etc) for that user, and will let the user use the website like he would normally via a browser.
  2. Another module will just continuous perform CPU intensive computations, without ever blocking any part of the application.
  3. Another module will render a full fledged Javascript charting app.

And so on. There are a number of such heavy weight modules in this application so using a threading approach is not desirable as basically these modules needs to run in their separate memory space and will act as child processes of the MainWindow process. The communication between the processes will be nicely handled using D-Bus, SharedMemory.

But what i can't figure out is how to actually create these child processes when the user clicks on the specific actions/buttons in the MainWindow. Again these modules are very much intergrated in one app and can't be called externally due to security and integrity constraints. So please let me know of any way to achieve this.

Upvotes: 2

Views: 1836

Answers (1)

One approach is to use the same executable, and control which module is launched using command line arguments. See a trivial example in this answer. Inter-process communication can be done using local sockets, you can also send slot calls across processes - see e.g. CuteIPC.

Upvotes: 2

Related Questions