Qt Flipable和MouseArea的组合在qml中出错

Qt Flipable和MouseArea的组合在qml中出错,qt,qml,Qt,Qml,这可能是一个bug,但请继续阅读: 在以下代码中,当FlipTable翻转(但翻转)时,FlipTable前面的鼠标earea保持活动状态,甚至从背面接管一些鼠标earea: import QtQuick 2.0 Rectangle { height: 500 width: 500 Flipable { id: flipable anchors.fill:parent property bool flipped: f

这可能是一个bug,但请继续阅读:

在以下代码中,当FlipTable翻转(但翻转)时,FlipTable前面的鼠标earea保持活动状态,甚至从背面接管一些鼠标earea:

import QtQuick 2.0

Rectangle {
    height: 500
    width: 500

    Flipable {
        id: flipable

        anchors.fill:parent

        property bool flipped: false

        front: Rectangle{
            color: "black"
            anchors.fill: parent

            Rectangle {
                color:"darkgrey"
                height: parent.height / 2
                width: parent.width / 2

                MouseArea {
                    anchors.fill: parent
                    onClicked: flipable.flip()
                }
            }
        }
        back: Rectangle {
            id: yellow
            color: "yellow"
            anchors.fill: parent

            MouseArea {
                anchors.fill: parent
                onClicked: yellow.color = "green"
            }
        }

        transform: Rotation {
            id: rotation
            origin.x: flipable.width/2
            origin.y: flipable.height/2
            axis.x: 0; axis.y: 1; axis.z: 0     // set axis.y to 1 to rotate around y-axis
            angle: 0    // the default angle
        }

        states: State {
            name: "back"
            PropertyChanges { target: rotation; angle: 180 }
            when: flipable.flipped
        }

        transitions: Transition {
            NumberAnimation { target: rotation; property: "angle"; duration: 400 }
        }

        function flip () {
            flipped = !flipped
        }
    }
}
当您按下灰色区域时,页面将翻转,如果再次按下(现在页面位于右侧后面),页面将再次翻转。正确的做法是,即使单击右上角,黄色方块也会变成绿色

谢谢

正确的做法是黄色的方块变成绿色, 即使在右上角单击时也是如此

我评论了这句话:

preventStealing: true // doesnt work with my QtQuick 1.0
它的行为方式是正确的


为什么要把它放在第一位?

启用前后元素交替解决了我的问题:

front: Rectangle {
    enabled: !parent.flipped
    ...
}

back: Rectangle {
    enabled: parent.flipped
    ...
}

你应该在…中添加一个明确的问题。。。不,还是不行,你能复制你的代码吗?也许你加了点什么?我对上面的内容进行了编辑,这样就不会出现错误(结果相同)。非常感谢您发布解决方案!花了5个小时试图解决这个问题。。。现在我觉得自己像个笨蛋P