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

Qt5: QTest::mouseClick doesn't set QApplication::keyboardModifiers anymore

    XMLWordPrintable

Details

    • I8518b06c4ce86ea7b35120e3353a45ea2a81d356

    Description

      A testcase like the attached one, which sends a mouse event to a QWidget using QTest::mouseClick, used to adjust QApplication::keyboardModifiers() in Qt4, but doesn't do so anymore in Qt5.

      It seems the code that changes modifier_buttons is now in QGuiApplicationPrivate::processMouseEvent, which is not called by QTest::mouseClick.

      qapplication.cpp:2983 (which is called) says
      // capture the current mouse/keyboard state
      but it only captures the mouse state, not the keyboard state.

      Should it capture keyboard state again, like in Qt4?

      But the interesting thing in all this is that outside of unit tests, it's all working fine (when I click on an actual widget, QApplication::keyboardModifiers() is set).
      So maybe the real fix would be that QTest::mouseClick works more like a real mouse click, going via the QWindow first, before being sent to the target QWidget? Not sure what this means exactly in terms of code changes though.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              dfaure David Faure (Private)
              dfaure David Faure (Private)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes