Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.15
-
None
Description
Run the attached test and you'll see this output:
QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") pressed with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier) QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") released with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier)
Then make the following changes
QTest::qWait(1000); // QTest::keyPress(window, Qt::Key_Shift); // QTest::keyRelease(window, Qt::Key_Shift);
and click the shift key once before the test finishes, and you'll see this output:
QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") pressed with modifiersQFlags<Qt::KeyboardModifier>(ShiftModifier) QDEBUG : tst_Untitled::testCase1() Key_Shift ("1000020", "") released with modifiersQFlags<Qt::KeyboardModifier>(NoModifier)
This difference (along with the fact that shift event handling/behaviour doesn't seem to be documented) makes it impossible to test shift events in an application: if I handle modifiers one way, the test will fail, and if I do it the other way, the actual application won't work as expected.
The only documentation I can find is https://doc.qt.io/qt-5/qkeyevent.html#modifiers, and it says:
Returns the keyboard modifier flags that existed immediately after the event occurred.
So is Qt Test wrong?
Attachments
Issue Links
- relates to
-
QTBUG-35968 support native event in qtestlib
- Open
-
QTBUG-26887 Qt5: QTest::mouseClick doesn't set QApplication::keyboardModifiers anymore
- Closed