Search code examples
c++qtevent-loopqeventloop

Qt or any other lang. Event Loop


I'm a c++ programmer on Qt platform.

I'm wondering, how does the event loop "knows" to which widget to send an event, mainly mouse/keyboard events? Is it done based on mouse coordinates and z-order? What about events from keyboard?

Thanks


Solution

  • The event loop doesn't know. This is done in other bits of code.

    The term you're looking for with the keyboard is "focus". Exactly one window has focus, systemwide (or at least one window per keyboard on multi-user systems). The OS delivers the keystrokes to that window. Qt just finds the Qt object from the native window handle. Similarly, mouse clicks are mostly handled by the OS.