我需要更改Button
它按下时的背景图像。如果我在Button
按下之前有背景图像,我需要在按下时更改该背景图像,然后在释放Button
时将其设置回原始背景图像。Button
这是我当前的代码:
property bool bImgChange: true
Button {
id: bu
x: 121
y: 40
iconSource: "q.png"
activeFocusOnPress: false
opacity: 1
checkable: true
checked: true
Layout.minimumWidth: 100
Layout.minimumHeight: 100
onClicked: {
if ( bImgChange == true )
{
bu.iconSource = "index.png"
bImgChange = false
}
else
{
bu.iconSource = "q.png"
bImgChange = true
}
}
}
上面的代码仅在单击时设置背景图像,Button
而我需要在按下和释放时更改背景图像。