qml
Animation
Suche…
Einfache Nummeranimation
Eine der grundlegendsten Animationen, auf die Sie stoßen könnten, ist die NumberAnimation . Diese Animation funktioniert, indem der numerische Wert einer Eigenschaft eines Elements von einem Anfangszustand in einen Endzustand geändert wird. Betrachten Sie das folgende vollständige Beispiel:
import QtQuick 2.7
import QtQuick.Controls 2.0
ApplicationWindow {
visible: true
width: 400
height: 640
Rectangle{
id: rect
anchors.centerIn: parent
height: 100
width: 100
color: "blue"
MouseArea{
anchors.fill: parent
onClicked: na.running = true
}
NumberAnimation {
id: na //ID of the QML Animation type
target: rect //The target item on which the animation should run
property: "height" //The property of the target item which should be changed by the animator to show effect
duration: 200 //The duration for which the animation should run
from: rect.height //The initial numeric value of the property declared in 'property'
to: 200 //The final numeric value of the property declared in 'property'
}
}
}
Verhaltensbasierte Animation
Mit einer verhaltensbasierten Animation können Sie angeben, dass bei Änderungen einer Eigenschaft die Änderung im Laufe der Zeit animiert werden soll.
ProgressBar {
id: progressBar
from: 0
to: 100
Behavior on value {
NumberAnimation {
duration: 250
}
}
}
Wenn sich in diesem Beispiel der Fortschrittsbalkenwert ändert, wird die Änderung über 250 ms animiert
Modified text is an extract of the original Stack Overflow Documentation
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow