QML Dialog mit konzentriert textField

arbeite ich an qt quick Anwendung, und ich will öffnen-dialog. In diesem dialog-Fenster TextField und will ich den Fokus auf diese textfiel nach dialog geöffnet ist.
Dieser code doesent Arbeit.

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
        }

    }
}

Ausgabe in der Konsole ist

qml: Schwerpunkt false

qml: Fokus verändert wahr

qml: Schwerpunkt false

Es so Aussehen, dass irgendwie der Fokus geändert wird, nachdem ich den Fokus auf textField

  • Dies funktioniert für mich in Qt 5.5. Der Fokus geht auf das TextField und es gibt vier Zeilen in der Konsole (false, true, false, true).
InformationsquelleAutor user3412372 | 2014-12-02
Schreibe einen Kommentar