The problem with my code below is that on US/UK keyboard layouts +
is generated with shift + =
, but when the user uses both the control and shift modifiers simultaneously, +
is not generated. This has been tested on Mac.
Keys.onPressed: {
if (event.modifiers & Qt.ControlModifier) {
if (event.key === Qt.Key_Minus) {
zoom(false)
event.accepted = true
} else if (event.key === Qt.Key_Plus) {
zoom(true)
event.accepted = true
}
}
}
Since control + +
and control + -
are standard shortcuts for zooming in applications I am certain that others have solved this. But how?
You have to use
Qt.ShiftModifier
for reacting onshift
key:Instead of
Key.onPressed
useShortcut
and itssequence
property :Your issue is mentionned in this section of the QKeySequence documentation.