这个qml文件,为什么state下的onclicked,没有触发呢?
这个qml,为什么state下onclicked,没有触发呢?
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" } } ]}