[Qt-interest] qt event loop in a DLL for thread signal slot mechanism

Gordon Schumacher gordon at rebit.com
Sun Nov 22 18:12:03 CET 2009


Lars Friedrich Lars wrote:
> Now, my qestions:
> - Did some of you tackle a similar problem?
> - Why does the Qt event loop 'steal' the keypress events although it is not a GUI application?
> - Can I 'pipe' the keypress events back to the Delphi-application's main thread (message queue)? Or could I connect the DLL's event loop directly to the Delphi-application's event loop?
> - Or did I completely misunderstand some Qt-fundamentals? Could I implement the signal/slot mechanism with some simpler Qt-tools than a QApplication? Maybe a lightweight event loop specific to thread signal/slot mechanism?
>   

I can't speak to the second item, but I've had to deal with a much
uglier version of this (my DLL gets loaded into, amongst other things,
Windows Explorer...!) so I have tried several different things, any or
some combination of them of which would work for various situations:

* use QCoreApplication::setEventFilter to "decide" what to do with a
given event (process, or pass along to Delphi).
* use a QTimer with a 0 timeout to handle idle processing and call
Delphi's processEvents equivalent
* if you're feeling really exceptionally clever or lucky, look at
QAxServer's code or the MFC migration solution to see how they are
integrating two disparate event loops

The latter is the best solution, but it's far and away the hardest!



More information about the Qt-interest-old mailing list