Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-117591

Let QQuick focus chain be independent of the logical hierarchical order



    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Quick: Other


      Today, the focus chain is implicitly defined by the logical hierarchical order of QQuickItems. The focus order can only be changed by reordering items in the hierarchy (e.g. reordering sibling items or reparenting items).

      This means that controls that dynamically create and destroy children (e.g ListView with a delegate) must take care and retain the order (this is already a known bug in ListView and GridView). Untangling the focus chain from the logical hierarchy means that these controls don’t need to take extra care about focus order when manipulating its child order.
      In addition, having a focus chain that is independent of the logical hierarchical order also allows the focus chain to be altered without having to change the logical hierarchy.



      The design will follow similar design found in QWidget. The focus chain will by default be initialized to the default logical hierarchical order (same order as today). The focus chain will be a long chain visiting all focus Items (or maybe absolutely all items), where

      • <Tab> moves from activeFocusItem() to the item after the focus item in the focus chain.
      • <Backtab> moves from activeFocusItem() to the item before the focus item in the focus chain.

      Note that it might skip items because they do not accept focus (or tabFocus).

      Focus chain can be implemented with a double linked list, where each QQuickItem will have:

      QQuickItem *focusNext;
      QQuickItem *focusPrev;

      Focus chain can alternatively be implemented with a QVector<QQuickItem*> on e.g. QQuickWindow. This will save some space (e.g. if all items are non-focusable), but there might be startup time penalties (might need to insert items in the middle of the vector etc).
      Order can be customized similar to

      QWidget::setTabOrder(a, c); 

      In QML, it could also take an array of items, e.g:

      Window.tabOrder: [a,c,b] 



        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            qt.team.quick.subscriptions Qt Quick and Widgets Team
            smd Jan Arve
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes