我想在QML中模仿Button,但为什么它只适用于 containsMouse
和 !containsMouse
,它不适用于 OnPressed
. 你能帮助我吗 ?谢谢 .
Item {
id: area
property string str_noPressed;
property string str_hover;
property string str_pressed;
Image {
id: background
width: 75; height: 75
source: userArea.containsMouse ? str_hover : str_noPressed
MouseArea {
id: userArea
anchors.fill: parent
onClicked: {}
onPressed: background.source = str_pressed
hoverEnabled: true
}
}
}
1 回答
显然,在按下按钮时,它还包含鼠标 .
我假设
containsMouse
优先于onPressed
. 尝试: