Qt QML StackView自定义转换

Qt QML StackView自定义转换,qt,qml,transitions,stackview,Qt,Qml,Transitions,Stackview,我已经阅读了Qt文档:但我仍然无法找出我做错了什么,因为我的代码应该生成淡入/淡出动画,但我得到的只是内容之间的瞬间闪烁。我希望我的描述足够清楚 StackView { id: stackView anchors.fill: parent delegate: StackViewDelegate { function transitionFinished(properties) { properties.exitIt

我已经阅读了Qt文档:但我仍然无法找出我做错了什么,因为我的代码应该生成淡入/淡出动画,但我得到的只是内容之间的瞬间闪烁。我希望我的描述足够清楚

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))
            }
        }
    }
}

动画的持续时间为10毫秒,或1/100秒。

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

替换

property Component pushTransition: StackViewTransition {

它应该会起作用。pushTransition实际上是上的一个属性


我仍在尝试让transitionFinished函数工作,因为他们的示例也不起作用。

这对我来说是可行的:

Window {
    id: mainWindowId
    width: 1280
    height: 800

    StackView {
       id: stackViewId
       anchors.fill: parent

      replaceEnter: Transition {
          PropertyAnimation{
              property: "opacity"
              from: 0
              to: 1
              duration: 300
          }
      }

      replaceExit: Transition {
          PropertyAnimation{
              property: "opacity"
              from: 1
              to: 0
              duration: 250
          }
      }

      initialItem: "yourStartingPage.qml"

    }
}
以及更改视图:

stackViewId.replace("yourOtherPage.qml")

嗯,我尝试了不同的值:1k、10k、100k仍然没有结果。在我的案例中,我发现Transition完成了工作。
stackViewId.replace("yourOtherPage.qml")