Buscar..


Animación de números simples

Una de las animaciones muy básicas que podrías encontrar es la NumberAnimation . Esta animación funciona cambiando el valor numérico de una propiedad de un elemento de un estado inicial a un estado final. Considere el siguiente ejemplo completo:

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

Animación basada en el comportamiento

Una animación basada en el comportamiento le permite especificar que cuando una propiedad cambia, el cambio debería animarse con el tiempo.

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

En este ejemplo, si algo cambia el valor de la barra de progreso, el cambio se animará más de 250 ms



Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow