qml 파일로드시 TextField 포커스를 활성화하려고합니다. 그러나 작동하지 않습니다. TestUi.qml 파일을로드 한 후 몇 가지 버튼과 onClick 메서드를 넣었습니다. recipientView.focus = true, 제대로 작동합니다. 문제는 뷰를 처음로드 할 때 기본 포커스가 활성화되지 않는다는 것입니다.Qt QML StackView 페이지를 표시 할 때 항목 (TextField)에 초점 맞추기
TestUi.qml
import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.0
Page {
function init() {
recipientView.focus = true;
}
TextField {
id: recipientView
Layout.fillWidth: true
font.pixelSize: 18
inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhEmailCharactersOnly
focus: true
placeholderText: "Email"
}
}
main.qml
onComposeBtnClicked: {
rootStackView.push(test)
test.init()
}
TestUi {
id: test
visible: false
}
'Component.onCompleted : recipientView.focus = true;'를 통해 설정하려고 했습니까? – DuKes0mE
앱로드가 시작되면 Component.onCompleted가 어떤 페이지인지와 상관없이 실행됩니다. 나는 아무 도움도하지 않았다 – nAkhmedov