QKeyCombination issue
-
I am using user-definable
QKeyCombination
s, which works well except for some characters.For example, on my keyboard, hitting "=" creates a
QKeyCombination(QFlags<Qt::KeyboardModifier>(ShiftModifier), Qt::Key_Equal)
because I need to press the shift key to enter an equal character (in a way it is the same asQKeyCombination(QFlags<Qt::KeyboardModifier>(ShiftModifier), Qt::Key_0)
, but that is not the combination that is delivered by the event).The problem now is that when I record the same keystroke with a
QKeySequenceEdit
widget, I getQKeyCombination(QFlags<Qt::KeyboardModifier>(NoModifier), Qt::Key_Equal)
.Obviously, the
ShiftModifier
is kind of implicit in theQt::Key_Equal
value.My question now is how I should compare keystrokes so that the two match, but the keyboard modifiers are respected otherwise.
I guess I am looking at some form of "canonical key combination" that is delivered in the same form in the events and by
QKeySequenceEdit
...(I am using Qt 6.2 if that matters. I found a comment regarding these problems here [https://doc.qt.io/qt-5/qkeysequence.html#keyboard-layout-issues], but my issue is a bit different. I don't want do distinguish between Shift-0 and Shift-= or just =, but just have a way that produces that same QKeyCombination on a given machine)