animatedimage.qml Example File
imageelements/animatedimage.qml
import QtQuick 2.11
import Qt.labs.handlers 1.0
import "../shared" as Examples
Column {
width: 320
height: 480
spacing: 6
y: 12
AnimatedImage {
id: animation
source: "content/Uniflow_steam_engine.gif"
anchors.horizontalCenter: parent.horizontalCenter
speed: speedSlider.value
TapHandler {
onTapped: animation.playing = !animation.playing
}
}
Rectangle {
id: timeline
color: "steelblue"
width: animation.width
height: 1
x: animation.x
y: animation.height + 12
visible: animation.playing
Rectangle {
property int frames: animation.frameCount
width: 4; height: 8
x: (animation.width - width) * animation.currentFrame / frames
y: -4
color: "red"
}
}
Examples.Slider {
id: speedSlider
name: "Speed"
min: 0
max: 5
init: 1
width: 240
x: animation.x
Text {
font.pointSize: 12
text: Math.round(animation.speed * 100) + "%"
x: animation.width - width
anchors.verticalCenter: parent.verticalCenter
anchors.margins: 6
}
}
Examples.Button {
text: "Reset"
enabled: speedSlider.value !== 1
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
speedSlider.setValue(1)
animation.playing = true
}
}
}