[Development] QTest::mouseClick doesn't set QApplication::keyboardModifiers anymore
David Faure
faure at kde.org
Mon Jul 30 11:30:15 CEST 2012
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.
--
David Faure, faure at kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tst-qwidget.diff
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120730/14a28bf3/attachment.bin>
More information about the Development
mailing list