QML: move to next control in form

I've defined a new component, TextFieldMoveOnReturn.qml

import QtQuick 2.0
import QtQuick.Controls 1.1

TextField {
    Keys.onReturnPressed:  nextItemInFocusChain().forceActiveFocus()
}

If you use this one instead of TextField, you get the required behaviour

edit a better solution: define a new component GridLayoutNextOnReturn.qml

import QtQuick 2.0
import QtQuick.Layouts 1.1

GridLayout {
    Keys.onReturnPressed: {
        for (var i = 0; i < children.length; ++i)
            if (children[i].focus) {
                children[i].nextItemInFocusChain().forceActiveFocus()
                break
            }
    }
}

and use normal TextField inside - works like a charm

Tags:

Qt

Qml

Qtquick2