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

Allow turning arbitrary Qt Quick items into FocusScope

    XMLWordPrintable

Details

    • All

    Description

      Keyboard handling in Qt Quick is tricky.
      One important element (that many people don't completely grasp) are focus scopes.

      A focus scope "divides" the tree of Qt Quick elements, so that focus can be remembered within a sub tree. This is for example relevant when the user can navigate between several containers which have a sub-focus or between dialogs that should remember the focus.

      I'll use Dialog as example here, assuming the UI is split in two "Dialogs" that each should remember their respective focus internally.

      The current way, FocusScope being an explicit item, means that each dialog has to be a FocusScope. This leads to having to forward a lot of properties, since one would often like to have for example a Rectangle as root element of a dialog.

      SomeRootElement {
          FocusScope {
               id: dialog1
               // geometry here forwarded to inner element
               Rectangle { ... }
          }
          FocusScope {
               id: dialog2
               // geometry here forwarded to inner element
               Rectangle { ... }
          }
      }
      

      Is not very elegant, since it means forwarding all of the geometry.
      There are no great alternatives. If one could instead set a property "focusScope: true" things would be a lot easier.

      (I'm not quite sure about the best component, it's keyboard, not mouse/touch input, but there is no other input component...)

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            frederik Frederik Gladhorn
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes