I want to implement my own sequence for changing the focus of the active child widget using the Tab key. How to capture the Tab Key press event? I am using Qt5.2
If you want to change focus with Tab , you don't need to do those works, Qt has it as a feature.
First: set the desired widgets to be Qt::TabFocus
or Qt::StrongFocus
by QWidget::setFocusPolicy( Qt::FocusPolicy policy )
For example, if you want to rotate between 3 QLineEdit
and 1 QCombobox
, you have to assure that their focus policy have been set right. (Normally either Qt::TabFocus
or Qt::StrongFocus
will be set as default, but sometimes you might want to escape some widgets from being tabbed)
Second: go to designer mode and click "Edit Tab Order
" to enter the tab-order editing mode
Third: After seeing the numbers, click on them until you got the desired sequence order.
(Picture from Qt official site)