[SOLVED] Cross-process UI interactions (Qt 4.8, Windows)
I’m quite new on Qt platform, sorry if I ask for some trivial questions (you can kick me to HOWTO if I’ve missed some ;)
I need to create a system to permit the creation of plug-in in our application, which is obviously written with Qt.
The requirement are simple:
- Plug-in should live in another process (for security/stability reasons)
- Plug-in should have access to at least a QWidget (I guess that behind, it will be a class derived from QWidget) to plys with (add it own widgets, draw inside, etc.)
On other words, I would need a kind of screen server (in my app) and a screen client (in my plug-in). The last one should be perfectly transparent for the plug-in.
There is an old demonstration wrote by “Marius” (I guess a kind of Qt God?) which do exactly what I need here: A Lighthouse with Windows [labs.qt.nokia.com] but the code is quite old (2010/02) and does not compile at all on Qt 4.8 version.
It seems that all this is working on Linux, but I can’t choose the platform: it’s Windows.
Any suggestion are welcome!
Thanks a lot
Because you need to isolate the plugin in another process you’ll have to deal with Inter Process Communication (IPC).
On Windows there are two ways of doing this with Qt: shared memory and sockets. Shared memory can work but it’s usually overkill to implement or maintain… You should maybe look at TCP/IP and design some sort of client/server protocol for the plugin to interact with your main application.
Otherwise, I think you can use Windows native SendMessage/PostMessage to do some remote calls across processes given a window handle.
Thanks for your answer.
We finally choose to use some IPC for communication between processes, but the real challenge was the display … how to display from a process into another process window ?
This was solved by using, on Windows platform, the API function ::SetParent which permit to attach a window as a child of another window. This works across process boundary, so our problem is solved.
Once again, thanks!
I have to execute a QWidget (in fact a QAxWidget) into an other process to protect my application from ActiveX crashes.
If I understand well, you used the SetParent() function to attach two widgets running in two different processes and then created an IPC protocol to handle signals, slots, method calls, etc… Am I right ?