1
我想模仿QML中的Button,但为什么它只适用于containsMouse
和!containsMouse
,它不适用于OnPressed
。你可以帮我吗 ?谢谢。如何模仿QML中的按钮
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
}
}
}
感谢您的帮助第一..对不起。有一种错误:无效的属性赋值:“containsMouse”是一个只读属性..这是我在我的代码错误。我更新了它。然后 ? – 2012-03-18 16:54:34
是啊,对不起。答案已更新。 – Koying 2012-03-18 18:26:35