[Development] Event loop of Qt window in DLL injected into another process

Tim Blechmann tim at klingt.org
Mon Oct 20 06:36:47 CEST 2014

>> Hello, I have a problem with event loop. I am creating DLL which I am
>> injecting into MFCapplication – my dll spawns a qt window. it works fine,
>> except ‘input’ to spawned window is blocked: for ex. i have edit box, i am
>> typing into it and nothing happens – unless, I resize / minimalzie window
>> then it’s somehow ‘flushed’. does anyone have any idea why this happen?
>> Here is my code: http://pastebin.com/iXqnwwCu I am using Qt version
>> 5.3.2
> The usual answer is to give Qt the event loop. If you control the host 
> application, you can create a QAbstractEventDispatcher to make it work with 
> the MFC application. Or you can use the MFC migration framework (I think it's 
> only available for enterprise customers).

if you are referring to the qtwinmigrate, in my experience it is pretty
broken ... registering, but not cleaning up itself which results in
crashes when unloading the dll and the like ...

one important point when injecting a function into the mfc event loop
manually is to guard it against infinite recursion, as it may be called
from qt_GetMessageHook ...

> If you can't do any of those, you should use modal dialogs and use exec() for 
> your Qt dialog. You'll be able to interact with the Qt dialog only, not the 
> rest of the application, for the duration of the dialog.

More information about the Development mailing list