I want to handle two key events Ctrl + Tab and Ctrl + Shift + Tab in order to switch between tabs in my application (forward and backward, respectively). However, this does not seem to work properly.
This is my current code (minimal example):
import QtQuick 1.1 Item { width: 100 height: 100 focus: true Keys.onPressed: { if(event.modifiers & Qt.ControlModifier) { if(event.key === Qt.Key_Tab) { if(event.modifiers & Qt.ShiftModifier) console.log('backward') else console.log('forward') } } } }
I ran this piece of code using qmlviewer (Qt version 4.8.2)
Exit when you press Ctrl + Tab :
forward forward
Exit when you press Ctrl + Shift + Tab :
no one
So, I see two errors: the first key sequence is processed twice, and the other is not at all.
- EDIT: The reason why the other is not processed at all is solved, see comments.
Why is this happening and how can I solve it?
Note. I already use Qt desktop components in my application, so keep this in mind if you know a solution that requires this module.
leemes
source share