2014-04-01 87 views
2

我已经通过了Qt文档:Qt StackView但我仍然无法弄清楚我做错了什么,因为我的代码应该会产生淡入/淡出动画,但是我得到的只是瞬间闪烁内容。我希望我的描述足够清楚。QML 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)) 
      } 
     } 
    } 
} 

回答

6

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

pushTransition: StackViewTransition { 

更换

property Component pushTransition: StackViewTransition { 

,它应该工作。 pushTransition其实是StackViewDelegate

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

+0

其实,我发现transitionFinished在我的情况下工作。 – Nadarian

1

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

+0

嗯,我尝试了不同的值:1k,10k,100k还没有结果 – Nadarian