2014-04-01 164 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