SequentialAnimation中ScaleAnimator之后的PropertyAction

时间:2017-06-28 12:30:31

标签: qt qml qt5 qtquick2 qt-quick

当项目进入“已选择”状态时,动画正常工作。但是当元素从“已选择”状态传递时,仅触发ScaleAnimator。

为什么PropertyAction会失败?

import QtQuick 2.7
import QtGraphicalEffects 1.0

Item {
    id: item

    width: 200
    height: 200

    Rectangle {
        id: rect
        color: "red"
        anchors.fill: parent
    }

    onZChanged: console.log(z)

    states: State {
        name: "SELECTED"
        when: mouseArea.containsMouse
        PropertyChanges { target: rect; color: "blue" }
    }

    transitions: [
        Transition {
            to: "SELECTED"            
            SequentialAnimation {
                PropertyAction {//work fine
                    target: item
                    property: "z"
                    value: 1
                }
                ScaleAnimator {//work fine
                    target: rect
                    from: 1
                    to: 1.25
                }
            }
        },
        Transition {
            from: "SELECTED"
            SequentialAnimation {
                ScaleAnimator {//work fine
                    target: rect
                    from: 1.25
                    to: 1
                }
                PropertyAction {//not work
                    target: item
                    property: "z"
                    value: 0
                }
            }
        }
    ]

    MouseArea {
        id: mouseArea
        anchors.fill: rect
        hoverEnabled: true
    }
}

在日志中只会将z更改为1.

0 个答案:

没有答案