按下按钮效果似乎不起作用

时间:2013-02-05 14:56:02

标签: qt qml meego

// 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
            }

        }
    }
$ onClicked $属性可以做,但我有一个新闻发布流程,该怎么办?

1 个答案:

答案 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}
        }
        ]
    }