En esta página

NumberAnimation QML Type

Anima los cambios en los valores de tipo qreal. Más...

Import Statement: import QtQuick
Inherits:

PropertyAnimation

Inherited By:

SmoothedAnimation and SpringAnimation

Propiedades

Descripción detallada

NumberAnimation es un PropertyAnimation especializado que define una animación a aplicar cuando cambia un valor numérico.

Aquí se muestra una NumberAnimation aplicada a la propiedad x de un Rectangle como fuente de valor de la propiedad. Anima el valor de x desde su valor actual hasta un valor de 50, a lo largo de 1000 milisegundos:

import QtQuick

Rectangle {
    width: 100; height: 100
    color: "red"

    NumberAnimation on x { to: 50; duration: 1000 }
}

Como cualquier otro tipo de animación, una NumberAnimation se puede aplicar de varias maneras, incluyendo transiciones, comportamientos y fuentes de valor de propiedad. La documentación Animación y Transiciones en Qt Quick muestra una variedad de métodos para crear animaciones.

Tenga en cuenta que NumberAnimation puede no animar suavemente si hay cambios irregulares en el valor numérico que está siguiendo. Si este es el caso, utilice SmoothedAnimation en su lugar.

Véase también Animación y transiciones en Qt Quick y Qt Quick Ejemplos - Animación.

Documentación de propiedades

from : real

Esta propiedad contiene el valor inicial de la animación.

Por ejemplo, la siguiente animación no se aplica hasta que el valor de x haya alcanzado 100:

Item {
    states: [
        // ...
    ]

    transitions: Transition {
        NumberAnimation { properties: "x"; from: 100; duration: 200 }
    }
}

Si NumberAnimation se define dentro de Transition o Behavior, este valor es por defecto el valor definido en el estado inicial de Transition, o el valor actual de la propiedad en el momento en que se activa Behavior.

Véase también Animación y transiciones en Qt Quick.

to : real

Esta propiedad contiene el valor final de la animación.

Si NumberAnimation se define dentro de Transition o Behavior, este valor es por defecto el valor definido en el estado final de Transition, o el valor del cambio de propiedad que desencadenó Behavior.

Véase también Animación y transiciones en Qt Quick.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.