QML:NumberAnimation 不能引用其父 SequentalAnimation

QML: NumberAnimation can't refer to its parent SequentalAnimation

我的代码:

import QtQuick 2.5
import QtQuick.Window 2.2

Window {
    visible: true
    width: 640
    height: 480
    property double angle: 0

    SequentialAnimation on angle {
        property int myDuration: 3000 // const
        NumberAnimation {
            from: -30.0
            to: 30.0
            duration: parent.myDuration
            easing.type: Easing.InOutSine
        }
    }
}

我在“parent.myDuration”行收到此错误:

ReferenceError: parent is not defined

有什么想法吗?

parent is a property of Item, an Animation is not a visual item, it inherits from QtObject.

Animation中没有属性来引用其父动画组。 你可以做的是为你的 SequentialAnimation 设置一个 id 并在你的 NumberAnimation

中引用这个 id