【1】设置鼠标区域,hoverEnabled=true
Rectangle {
id: mouseArea
width: 500
height: 500
x: 0
y: 0
}
MouseArea {
anchors.fill: mouseArea
hoverEnabled: true
onEntered: {
console.log("鼠标移入")
}
onExited: {
console.log("鼠标移出")
}
}
【6】注意事项
1、鼠标区域,mouseArea宽高不能为0
2、鼠标区域上方不能有遮挡,譬如 StackView