首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

这个qml资料,为什么state下的onclicked,没有触发呢

2012-07-15 
这个qml文件,为什么state下的onclicked,没有触发呢?这个qml,为什么state下onclicked,没有触发呢?C/C++ cod

这个qml文件,为什么state下的onclicked,没有触发呢?
这个qml,为什么state下onclicked,没有触发呢?

C/C++ code
import QtQuick 1.1Rectangle{    id:mainRec    width: 400    height: 400    Rectangle    {        id:topleftRec        width: 150        height: 150        anchors{left: parent.left;top: parent.top;leftMargin: 30;topMargin: 30;}        color: "red"        focus:true        MouseArea { anchors.fill: topleftRec; onClicked: topleftRec.state = '' }    }    Rectangle    {        id:toprightRec        width: 150        height: 150        anchors{right: parent.right;top: parent.top;rightMargin: 30;topMargin: 30;}        color: "blue"        MouseArea { anchors.fill: toprightRec; onClicked: toprightRec.state = 'topright' }    }    Rectangle    {        id:bottomleftRec        width: 150        height: 150        anchors{left: parent.left;bottom: parent.bottom;leftMargin: 30;bottomMargin: 30;}        color: "green"        MouseArea { anchors.fill: bottomleftRec; onClicked: bottomleftRec.state = 'bottomleft' }    }    Rectangle    {        id:bottomrightRec        width: 150        height: 150        anchors{right: parent.right;bottom: parent.bottom;rightMargin: 30;bottomMargin: 30;}        color: "yellow"        MouseArea { anchors.fill: bottomrightRec; onClicked: bottomrightRec.state = 'bottomright' }    }   states:    [        state        {            id:topleft            //name: "topleft"            PropertyChanges { target: topleftRec;color:"black" }        },        state        {            name: "topright"            PropertyChanges { target: toprightRec;color:"black" }        },        state        {            name: "bottomleft"            PropertyChanges { target: bottomleftRec;color:"black" }        },        state        {            name: "bottomright"            PropertyChanges { target: bottomrightRec;color:"black" }        }    ]}


[解决办法]
探讨

你的states是描述的mainRec的状态,而bottomrightRec等里面onClicked是改变bottomrightRec自己的状态,mainRec的状态并没有被改变

热点排行