// MainPage.qml
Button{
id: pushI
text: qsTr("录音")
//onClicked: label.visible = true
MouseArea
{
anchors.fill: parent
MyItem { id: inputA}
onPressed:
{
inputA.on_pressed()//my c++ class method
}
onReleased:
{
inputA.on_released()//my c++ class method
}
}
}
答案 0 :(得分:0)
解决问题
Button{
id: button
state: "RELEASED"
text: qsTr("录音")
MouseArea
{
anchors.fill: parent
MyItem { id: inputA}
onPressed:
{
inputA.on_pressed()
button.state = "PRESSED"
}
onReleased:
{
inputA.on_released()
button.state = "RELEASED"
}
}
states: [
State {
name: "PRESSED"
PropertyChanges { target: button; checked: true}
},
State {
name: "RELEASED"
PropertyChanges { target: button; checked: false}
}
]
}