[Qt-components] Key navigation

Alan Alpert 416365416c at gmail.com
Mon Jan 7 18:12:44 CET 2013


On Sun, Jan 6, 2013 at 7:54 AM, Alberto Mardegan
<mardy at users.sourceforge.net> wrote:
> On 01/02/2013 11:37 AM, Alberto Mardegan wrote:
>> It would be nice if there was a default key navigation flow, implicitly
>> built according to the placement of the components inside a window; then
>> the keyNavigation properties could be used to override this when needed.
>> The QtWidgets library also provides a default key navigation, so it
>> seems sensible if the QML components have the same.
>
> Here is a possible implementation:
>
>    https://codereview.qt-project.org/#change,44029
>
> It introduces a FocusChain object which can be used like this:
>
> ==================
> FocusChain {
>    id: focusChain
>    rootItem: widgetContainer
> }
>
> Grid {
>    id: widgetContainer
>    ...grid properties...
>
>    Keys.onTabPressed: focusChain.focusNext(Qt.Key_Tab)
>    Keys.onBacktabPressed: focusChain.focusNext(Qt.Key_Backtab)
>
>    Button { ... }
>    ComboBox { ... }
>    ...other widgets...
> }
> ==================

Since this is based around layouting behavior, why not build it into
the Qt Components layouts? Surely they're a more realistic usecase for
components than using the positioners. GridLayout could automatically
have a FocusChain, leading to no further code required for the user
(int the common case).

--
Alan Alpert



More information about the Qt-components mailing list