Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73155

QWheelEvent lost/ignored while moving mouse when paint event is slow

XMLWordPrintable

    • Linux/X11

      Update: patch provided below, see comments.

      While porting a CAD application from Qt4 to Qt5 I noticed that mouse wheel events are often ignored when the mouse is simultaneously being moved and the application is busy drawing things. The events get through just fine when the mouse is not moving and the application is idle, but when I move the mouse it triggers paint events continuously, and nearly all mouse wheel events are lost. When one event finally gets through, the 'delta' value contains the accumulated value from all the ignored events, so clearly the events did reach Qt, but simply weren't passed on to the application.

      I suspect that the bug is located in the code that is responsible for merging mouse events: apparently the merged mouse move events are masking the merged mouse wheel events.

      The problem in this StackOverflow post seems to be caused by the same bug.

      I've attached a minimal example that reproduces the problem. There's a sleep(100) call in the paint event to simulate slow painting in the CAD application. The example app draws a circle that follows the mouse, the size of which can be changed with the mouse wheel. When the mouse is moved continuously, it becomes nearly impossible to change the size of the circle since nearly all the wheel events are lost.

        1. MainWindow.cpp
          1 kB
          Maarten Baert
        2. MainWindow.h
          0.3 kB
          Maarten Baert
        3. main.cpp
          0.2 kB
          Maarten Baert
        4. patch-qtbug-73155.patch
          5 kB
          Maarten Baert
        5. patch2-qtbug-73155.patch
          4 kB
          Maarten Baert
        For Gerrit Dashboard: QTBUG-73155
        # Subject Branch Project Status CR V

            Unassigned Unassigned
            maarten baert Maarten Baert
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There is 1 open Gerrit change