当前位置:编程学习 > wap >>

这个按照教程的QML文件鼠标点击为何没反应

我按照QTQUICK 创建一个“Transations”的例程,做的,鼠标点击,状态没变化,而在“设计窗中”STATTE1和STATE2的状态都是可以的,下面是QML 源程序
import QtQuick 1.0

Rectangle {
    id: page
    width: 640
    height: 480
    color: "#343434"

    Image {
        id: icon
        x: 10
        y: 20
        source: "states.png"
    }

    Rectangle {
        id: topLeftRect
        width: 64
        height: 64
        color: "#00000000"
        radius: 6
        anchors.left: parent.left
        anchors.leftMargin: 10
        anchors.top: parent.top
        anchors.topMargin: 20
        border.color: "#808080"

        MouseArea {
            anchors.fill: parent
                 onClicked: page.state = ''
            }
        }

        Rectangle {
            id: middleRightRect
            x: -3
            y: -5
            width: 64
            height: 64
            color: "#00000000"
            radius: 6
            border.width: 1
            anchors.right: parent.right
            anchors.rightMargin: 10
            anchors.verticalCenter: parent.verticalCenter
            border.color: "#808080"
            MouseArea {
                id: mousearea1
               onClicked: page.state = 'State1'
            }
        }

        Rectangle {
            id: bottomLeftRect
            y: -6
            width: 64
            height: 64
            color: "#00000000"
            radius: 6
            anchors.left: parent.left
            anchors.leftMargin: 10
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 20
            border.color: "#808080"
            MouseArea {
                id: mousearea2
                onClicked: page.state = 'State2'
            }
        }
        states: [
             State {
                 name: "State1"

                 PropertyChanges {
                     target: icon
                     x: middleRightRect.x
                     y: middleRightRect.y
                 }

             },
             State {
                 name: "State2"

                 PropertyChanges {
                     target: icon
                     x: bottomLeftRect.x
                     y: bottomLeftRect.y
                 }
            }

         ]


} --------------------编程问答-------------------- 你是移动设备。还是PC?  如果可以的话。DEBUG看看。看看是不是事件没有被处理。 --------------------编程问答-------------------- 好,谢谢,试试看
补充:移动开发 ,  Qt
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,