2016-12-13 20 views
0

私は数秒間表示する必要がある画像があります。どのようにQMLでそれを行うには?QMLで数秒間画像を表示するには?

例はありますか?

私はこの状態を持っていますが、その状態は現れません。私は、IR繰り返し

 Item { 
     id: myimageanimation 
     x:0 
     y:0 
      z:2000 

Image { 
     id: rect 
     x: 293 
     y: 242 
     source: "assets/ic_sound_popup_off.png" 
    } 


states: [ 
     State { 
      name: "actif" 
      PropertyChanges { 
       target: rect 
       visible:true 

      } 
    }, 
     State { 
      name:"inactif" 
      PropertyChanges { 
       target:rect 
       visible : false 
      } 
    } 
    ] 

    transitions: [ 
     Transition { 
      NumberAnimation { 
       property: "visible" 
       duration:2000 
       easing.type: Easing.InOutQuad 
      } 
     } 
    ] 
+0

表示方法は?ポップアップで?あなたの窓のどこかに?コード/スクリーンショットがありますか? –

+0

'Timer'オブジェクトを使用します。 – dtech

+0

@GeorgSchölly私の記事を見て、私はいくつかのコード例がありますが消えません。 –

答えて

1

は、あなたが使用できるようにしても必要PropertyAnimationvisible

Window { 
    id: root 
    visible: true 
    width: 1200 
    height: 1000 
    Image { 
     id: rect 
     anchors.fill: parent 
     source: 'qrc:/Pics/mypic.png' 
    } 

    PropertyAnimation { 
     running: true 
     target: rect 
     property: 'visible' 
     to: false 
     duration: 5000 // turns to false after 5000 ms 
    } 
} 

あるいは、@ddriverが述べたように、タイマーオブジェクトを使用して、例えばあなたはまた、それを衰退するアニメーションを使用することができます

Window { 
    id: root 
    visible: true 
    width: 1200 
    height: 1000 
    Image { 
     id: rect 
     anchors.fill: parent 
     source: 'qrc:/Pics/mypic.png' 
    } 

    Timer { 
     interval: 5000 // triggers every 5000 ms 
     onTriggered: rect.visible = false 
     running: true 
    } 
} 

:このよう

Window { 
    id: root 
    visible: true 
    width: 1200 
    height: 1000 
    Rectangle { 
     id: rect 
     anchors.fill: parent 
     color: 'red' 
     visible: opacity > 0 
    } 

    SequentialAnimation { 
     running: true 
     PauseAnimation { 
      duration: 4000 // Wait for 4000ms 
     } 
     NumberAnimation { 
      target: rect 
      property: 'opacity' 
      to: 0 
      duration: 1000 // Then fade away for 1000ms 
     } 
    } 
} 

タイマーを使用すると、同じことをachiveするBehavior on opacityを使用することができます。

+0

ありがとうございます。タイマーは私の場合はもっと簡単です。 –

関連する問題