Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
4.6.2, 4.8.3, 5.0.0 Beta 2
-
None
-
Windows XP; US keyboard layout
-
5055183bc5a8288976f58c65b52276ad17491cad 98b49f88fa1dfe593bf8e4291bd12419d47c26aa
Description
According to the document, QKeyEvent::key() should return platform independent key code value for the key pressed. but on windows, with US keyboard layout, it seems that the key is not correct when Shift is combined with Ctrl.
For example,
correct cases:
- by pressing Shift+ '=' we get Qt::Key_Plus and modifier for Shift
- by pressing Alt+Shift+ '=' we get Qt::Key_Plus and modifier for Shift+Alt
wrong case:
- by pressing Ctrl+Shift+'=', we get '=' and modifier for Ctrl+Shift.
On linux, it works fine.
The following code can be used as test case:
#include <QKeyEvent> #include <QApplication> #include <QWidget> class MainWin: public QWidget { public: MainWin(QWidget*p = NULL); ~MainWin(){}; void keyPressEvent(QKeyEvent*); }; MainWin::MainWin(QWidget*p ):QWidget(p) { } void MainWin::keyPressEvent(QKeyEvent*ev) { qWarning("%d, %d, %d, %08x", ev->key(), ev->nativeVirtualKey(), Qt::Key_Plus, (int)ev->modifiers()); return QWidget::keyPressEvent(ev); } int main(int argc, char* argv[]) { QApplication a(argc, argv); MainWin mw; mw.show(); return a.exec(); }