No, and it has to do with the event loop, QApplication is designed as a singleton.s there a way to call QApplication across multiple threads within a single dll?
What you can do is spawn separate processes using QProcess.
You wont have a direct access to their events (as you mentioned you need) but you can overcome it the usual way for this kind of a scenario by using an IPC mechanism of your choice.
This will involve code that inspects the events and dispatches them (or rather, data about them) over the IPC.
Or, you could go about implementing your own "application" object building it around a QEventLoop - not something for beginners.
However, reading your post I am not sure you actually need multiple QApplications, what you seem to need is merely "multiple UI's."
I am putting quotes because you only really have one UI per QApplication - which can be made of many views and windows etc.
You could have threads each doing his thing, and talking to a different window or UI - and all these threads can share the even processing of your QApplication, each thread can be killed or spawned.
When the last thread exists, you can close your QApplication too.
To be clear:
your threads will drive the business logic, but they will be talking to a UI living the in the QApplication gui thread.
None of the above options are trivial, but the last one with threads seems to me the most sensible, and probably the most practical to implement.
Bookmarks