QML StackView自定义转换

Nad*_*ian 2 qt transitions qml stackview

我已经完成了Qt文档:Qt StackView但我仍然无法弄清楚我做错了什么,因为我的代码应该产生淡入/淡出动画,但我得到的只是内容之间的瞬间闪烁.我希望我的描述充分而清晰.

StackView {
    id: stackView
    anchors.fill: parent
    delegate: StackViewDelegate {

        function transitionFinished(properties)
        {
            properties.exitItem.opacity = 1
        }

        property Component pushTransition: StackViewTransition {
            PropertyAnimation {
                target: enterItem
                property: "opacity"
                from: 0
                to: 1
                duration: 10
            }
            PropertyAnimation {
                target: exitItem
                property: "opacity"
                from: 1
                to: 0
                duration: 10
            }
        }
    }
    initialItem: Item {
        width: parent.width
        height: parent.height
        ListView {
            model: pageModel
            anchors.fill: parent
            delegate: AndroidDelegate {
                text: title
                onClicked: stackView.push(Qt.resolvedUrl(page))
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Sco*_*ott 6

我遇到了同样的问题,并请求他们的支持 - 他们的例子是错误的.

更换

property Component pushTransition: StackViewTransition {
Run Code Online (Sandbox Code Playgroud)

pushTransition: StackViewTransition {
Run Code Online (Sandbox Code Playgroud)

它应该工作.pushTransition实际上是一个属性StackViewDelegate

我仍然试图让transitionFinished函数工作,因为他们的例子也不起作用.