qml中action属性的使用

101 阅读1分钟



Button { width:100; height:80; action: idActBeginGrab; }//这里定义一个按钮,使用了action属性。

这里定义一个Action,注意id要对应

Action {

        id: idActBeginGrab; text: qsTr("Start");

\

        enabled: ( idRootPriv.m_vm != null ? ! idRootPriv.m_vm.prop_isVideoGrabbing : false );

\

        onTriggered: { jsCmdBeginGrab( ); }

\

    }

然后我们在界面上可以看到,这个按钮的text属性显示的是action中text的字符。

enabled:使用了三目运算。

onTriggered:是按钮点击事件,

这样和按钮的onClicked的用法有相同效果