Search code examples
qtfocus

Qt focus changing order


For example we have a groupbox with some amount of lineEdits.
When user press Tab focus from one lineEdit changed to other.
How to make focus change in the specific order?
In my Dialog focus changed in a very strange way.
For example cursor jumps this way 1 3 2 4 lineEdits. I want to make it jumping 1 2 3 4 lineEdits
I think that the order is such because I added this line edits in such order...but remaking all GUI is not a solution for me...


Solution

  • In the designer you should select Edit->Edit Tab Order (blue numbers will appear). Then you should click on your widgets in the order you want them to be (numbers will change). After you are done, you should select Edit->Edit Widgets (or press F3).

    If you are not using designer, use:

    void QWidget::setTabOrder ( QWidget *first, QWidget *second );