Matthias
Matthias

Reputation: 235

Qt/QML Focus with Nested Views

I have a StackView. In that I open a SplitView. The SplitView contains two parts. In one part I have a TextField.

When I open the SplitView the focus shall be put on the TextField.

I tried many things: focus:true or forceActiveFocus(). I have no ideas anymore. Maybe someone could give me a hint.

Upvotes: 0

Views: 87

Answers (1)

Matthias
Matthias

Reputation: 235

The solution is pretty simple:

Component.onCompleted: {
    Qt.callLater(correctFocus)
}

function correctFocus () {
    callTextField.forceActiveFocus();
}

Upvotes: 0

Related Questions