PDA

View Full Version : Message loops of different GUI toolkits



elizabeth.h1
29th July 2009, 08:46
Hello

I recently posted on this forum about how to show qt dialog from mfc application. I was using the mfc/qt migration solution.
http://www.qtcentre.org/forum/f-qt-programming-2/t-modeless-dialog-in-qt-dll-loaded-in-existing-non-qt-app-22844.html

I also noticed that I can show modal dialog box (has its own local message loop) without using the mfc/qt migration solution. The same does not hold true for modeless dialog box.

My question is why the message loop of the mfc application can't just retrieve the messages for the modeless qt dialog from the thread message queue and dispatch them to the appropriate window procedure ?

That is why messages generated from one gui toolkit (qt) can not be fetched by the message loop of another gui toolkit (mfc) , if the both toolkits are using the underlying win32 api for window management?

I also search the posts of this forum about using the mf/qt migration solution, and came to the information that mf/qt migration solution merges the message loops of the mfc and qt . So again, can someone explain what that means to merge the message loops of different gui toolkits ?

I really want to understand this concept. I am sure am missing something very obvious about why different gui toolkits can not be mixed together.

Thanks

wysota
29th July 2009, 08:51
My question is why the message loop of the mfc application can't just retrieve the messages for the modeless qt dialog from the thread message queue and dispatch them to the appropriate window procedure ?
Because they are incompatible.


So again, can someone explain what that means to merge the message loops of different gui toolkits ?
Additional code is injected into one of the loops to provide means of periodically running the other loop as both can't usually run at once (as they are probably both blocking).

elizabeth.h1
29th July 2009, 09:03
I am not understanding well why the message loops are incompatible.
I imagine that message loop from any gui toolkit looks essentially like the standard win32 loop with GetMessage ,TranslateMessage and DispatchMessage. If this is true , i was thinking that when mixing different toolkits in same app only one message loop should be present, and that message loop should retrive the messages from both toolkits.
sorry if this is stupid

wysota
29th July 2009, 09:14
I am not understanding well why the message loops are incompatible.
Because they use different concepts.

I imagine that message loop from any gui toolkit looks essentially like the standard win32 loop with GetMessage ,TranslateMessage and DispatchMessage. If this is true (...)
It's not. Qt events are translated from system events to objects and the whole event mechanism is embedded into the application itself. WinAPI is not object oriented. I guess the two reasons are sufficient.


i was thinking that when mixing different toolkits in same app only one message loop should be present, and that message loop should retrive the messages from both toolkits.

Yes, that's correct. That's why you have the migration package. An alternative is to implement a dispatcher for Qt events using other event mechanism by reimplementing QAbstractEventDispatcher just like it has been done to use glib event loop for Qt on Unix.

elizabeth.h1
29th July 2009, 09:30
ok now its more clear.
I should read the documenttaion for QEvent first :)
Thank u