Recherche…


Animation de numéro simple

Une des animations les plus élémentaires que vous pourriez trouver est l’ NumberAnimation . Cette animation fonctionne en changeant la valeur numérique d'une propriété d'un élément d'un état initial à un état final. Prenons l'exemple complet suivant:

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'
        }
    }
}

Animation basée sur le comportement

Une animation basée sur le comportement vous permet de spécifier que, lorsqu'une propriété change, la modification doit être animée au fil du temps.

ProgressBar {
    id: progressBar
    from: 0
    to: 100
    Behavior on value {
        NumberAnimation {
            duration: 250
        }
    }
}

Dans cet exemple, si quelque chose modifie la valeur de la barre de progression, la modification sera animée sur 250 ms



Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow