1 year ago
#327910
test me
Accessing KeyNaviagtion from a property alias
Is it possible to use a property alias and gain access to KeyNaviagtion, assign an object to it, such that I can navigate between the buttons: cornerButton
, messageButton
and callButton
? The cornerButton
will be used to close the pop up. The code below does not run. I am trying to understand the concept.
cornerButton.KeyNavigation.down: messageButton
cornerButton.KeyNavigation.right: messageButton
Popup {
id: root
property alias cornerButton: cornerButton
Button {
id: cornerButton
visible: true
}
}
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Popup {
//cornerButton.KeyNavigation.down: messageButton
//cornerButton.KeyNavigation.right: messageButton
Row {
id: buttonsRow
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
UniButton {
id: messageButton
anchors.top: parent.top
onClicked: {
hide();
}
Keys.onReturnPressed: clicked()
KeyNavigation.up: cornerButton
KeyNavigation.down: callButton.enabled ? callButton : null
KeyNavigation.left: cornerButton
KeyNavigation.right: callButton.enabled ? callButton : null
Keys.onPressed: {
if (event.key === Qt.Key_F2 && callButton.enabled) {
callButton.focus = true
}
}
}
UniButton {
id: callButton
anchors.top: parent.top
onClicked: {
hide();
}
Keys.onReturnPressed: clicked()
KeyNavigation.up: messageButton : null
KeyNavigation.left: messageButton
Keys.onPressed: {
if (event.key === Qt.Key_F1) {
messageButton.focus = true
}
}
}
}
}
} }
qt
qml
qt5
qtquick2
qt6
0 Answers
Your Answer