I am working on Qt quick application and I wanna open dialog. In this dialog window is TextField
and I want to set focus to this textField
after dialog
is open.
This code doesn't work.
function newFolder() {
newFolderDialog.visible = true
newFolderDialog.open()
}
Dialog {
id: newFolderDialog
title: "New folder"
height: 150
width: 300
standardButtons: StandardButton.Ok | StandardButton.Cancel
Column {
anchors.fill: parent
Text {
text: "Name"
height: 40
}
TextField {
id: newFolderInput
width: parent.width * 0.75
focus: true
onFocusChanged: console.log("Focus changed " + focus)
}
}
onVisibilityChanged: {
if(visible === true){
newFolderInput.text = ""
newFolderInput.focus = true
}
}
}
output to console is:
qml: Focus changed false
qml: Focus changed true
qml: Focus changed false
It look like, that somehow focus is changed after I set focus to textField