Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using tab key for navigation in TextEdit

Tags:

qt-quick

qml

I have two TextEdit boxes and one custom button widget, I wish to change focus in the following order using the tab key on my keyboard:

TextEdit1 <-> TextEdit2 <-> Button

I have specified something similar to the following for each widget in order to obtain the chain above:

KeyNavigation.tab: TextEdit2
KeyNavigation.backtab: TextEdit1

My problem is however that the tab keystroke is caught in the TextEdit, and cannot be used to navigate. How can I disable tabs in the TextEdit and instead use it for changing focus?

like image 529
Jonatan Avatar asked Oct 25 '25 06:10

Jonatan


1 Answers

I found the problem.

By default the key events are first sent to the item which is receiving the event - not to KeyNavigation. This behavior can be changed by setting

KeyNavigation.priority: KeyNavigation.BeforeItem

The complete code thus becomes

KeyNavigation.tab: TextEdit2
KeyNavigation.backtab: TextEdit1
KeyNavigation.priority: KeyNavigation.BeforeItem
like image 54
Jonatan Avatar answered Oct 28 '25 05:10

Jonatan