QML: move to next control in form

qml, qt, qtquick2

Solution

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

Problem

How can I move focus from one control to next one inside QML form? By default it works with `Tab` button but I need to change it to `Enter`. All the control are ordered with `Gridlayout` with 2 columns.

Original source