QML StackView自定义转换

时间:2014-04-01 11:35:15

标签: qt qml transitions 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))
            }
        }
    }
}

3 个答案:

答案 0 :(得分:6)

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

替换

property Component pushTransition: StackViewTransition {

pushTransition: StackViewTransition {

它应该有效。 pushTransition实际上是StackViewDelegate

上的属性

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

答案 1 :(得分:1)

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

答案 2 :(得分:1)

这对我有用:

blur = cv2.GaussianBlur(im,(5,5),0)
smooth = cv2.addWeighted(blur,1.5,im,-0.5,0)
edges = cv2.Canny(smooth,100,200)
edges_inverse_masked_data = cv2.bitwise_and(edges, edges, mask=inverse_mask)

对于更改视图:

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"

    }
}