Mouse events disappearing for non-Qt window on windows [Solved]



  • Hi,

    still relatively new to Qt but succeeded over the last weeks to replace our old obsolete-when-new GUI code with Qt and improve several things along the way as well. Now however I am running into a problem I so far have not been able to google my way out of.

    Some background:

    application has an opengl main window which is created outside Qt (most of this application is completely outside Qt), Qt windows are only used for (development) subfunctionality, just GUI.

    I am calling processEvents() from the main loop each frame.

    Using locally built Qt 4.7.4 on both platforms.

    Everything works fine on linux. The Qt windows behave properly and I can interact with the application/simulation in the main opengl window through mouse and keyboard just as was always possible.

    However, when I applied the same changes to incorporate Qt on windows the mouse no longer works in the main window. Keyboard does, but our mouse code never seems to get any WM_INPUT events. When I disable calling processEvents() the mouse works fine again. (but then obviously the Qt windows won't work properly)

    It seems Qt is catching mouse events intended for the main window and throwing them away/forgetting them instead of delivering them to the main window.

    Unfortunately I haven't found anything that points to this being a common occurrence (with a common simple solution).

    I did find "this":http://qt-project.org/forums/viewthread/502 thread referencing an issue with mouse events but the resolution mentioned there of compiling Qt with _WIN32_WINNT=0×501 defined does not make any difference.

    Any insights would be highly appreciated!



  • Hm...did i understand correctly? You are trying to catch mouse events on a window that's not part of your Qt Project? If yes, i think you need a hook, a system wide hook for windows.



  • I'm not sure what you mean by part of the Qt Project?

    The main window is created regularly without any Qt calls. The visualization library calls windows/opengl/X11 directly. Nothing Qt related is happening regarding the main window. The only extra is that the visualization library now creates a QApplication object and calls processEvents() in its main loop. This is done just to ensure there is one in a central and convenient location.

    From the same application (or actually linked in modules) other windows are created that are Qt windows.

    On Linux this works fine, on windows however the call to processEvents() causes no mouse events to arrive for the main window. PeekMessage calls from the visualization library don't get any WM_INPUT messages anymore, WM_KEYDOWN/WM_KEYUP still come through fine though.



  • Never mind! issue had nothing to do at all with Qt. The location processEvents() was being called meant that events delivered to the window proc by Qt correctly calling DispatchMessage were thrown away before the mouse driver code got to see them.

    Moving processEvents() to a slightly different location in the main loop solved this. Differences in event handling on Windows versus X11 made this not an issue on Linux.

    sorry for the noise..


  • Moderators

    Glad you got it fixed! Be sure and label the thread [Solved] by editing the title. Thanks!



  • Congratz and thumbs up! :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.