Wie kann ich mithilfe von QML untergeordnete Mouse-Hover-Ereignisse in die übergeordnete MouseArea aufnehmen?
Ich möchte das folgende Szenario in QML implementieren.
Hier ist ein Beispiel / vereinfachter Delegierter fürListView
Element:
Component {
Item {
id: container
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
container.ListView.view.currentIndex = index
container.forceActiveFocus();
}
onEntered: {
actionList.state = "SHOW";
myItem.state = "HOVER"
}
onExited: {
actionList.state = "HIDE";
myItem.state = "NORMAL"
}
Rectangle {
id: myItem
color: "gray"
anchors.fill: parent
Row {
id: actionList
spacing: 5; anchors.fill: parent
Image {
id: helpAction
source: "" //Some image address
width: 16; height: 16; fillMode: Image.PreserveAspectFit
states: [
State {
name: "NORMAL"
PropertyChanges { target: helpAction; opacity: 0.7 }
},
State {
name: "HOVER"
PropertyChanges { target: helpAction; opacity: 1.0 }
}
]
MouseArea {
hoverEnabled: true
anchors.fill: parent
onEntered: {
parent.state = "HOVER";
}
onExited: {
parent.state = "NORMAL";
}
}
states: [
State {
name: "SHOW"
PropertyChanges { target: actionList; visible: false }
},
State {
name: "HIDE"
PropertyChanges { target: actionList; visible: true }
}
]
}
//Other action buttons...
states: [
// `NORMAL` and `HOVER` states definition here...
]
}
}
}
}
Aber ich habe ein Problem mitMouseArea
.
InnereMouseArea
(actionButton) funktioniert bei nicht richtigentered
Veranstaltung. Wenn die Maus auf die Aktionstaste drückt, wird die äußere Maustaste gedrücktMouseArea
Brändeexited
Veranstaltung.
Gibt es einen Fehler in meinem Code? Wie kann ich ein solches Szenario generell in QML implementieren?