Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to correctly handle tab order in qml?



  • In my project I need to finalize the tab order onto the interface. I found that this order may be configured by setting the KeyNavigation.tab property in every not well sorted item.

    However my interface isn't just a basic interface with few items, it contains complex components, e.g SwipeView, many of them are embedded in others, or exists on pages which are loaded dynamically, and the interface may greatly vary depending on what the user is doing, e.g a swipe view may show a random page, or an item may be hidden until a given action is performed, and so on.

    For that reason I cannot simply define the "KeyNavigation.tab to the next item to focus", as suggested in the documentation. For example, how can I define the focus order when the next button to focus is a given button, unless another button become visible between? Or if the next item to focus depends on the current visible Page of a SwipeView?

    Some point are unclear for me. What happen e.g if I set the KeyNavigation.tab to point to a currently hidden item, which points itself to another visible item? Is the focus following the tab chain and passing directly to the visible item, or will it stuck on the hidden item?

    And I couldn't found any tool to help to manage the tab order, so is Qt providing a such tool, and where can I find it?

    Finally, how experimented developers are commonly handling a such situation?