En esta página

YAnimator QML Type

El tipo YAnimator anima la posición y de un elemento. Más información...

Import Statement: import QtQuick
Inherits:

Animator

Descripción detallada

Animator Los tipos son diferentes de los tipos de animación normales. Al utilizar un Animator, la animación se puede ejecutar en el hilo de renderizado y el valor de la propiedad saltará al final cuando la animación haya finalizado.

El valor de ` Item::y ` se actualiza una vez finalizada la animación.

El siguiente fragmento de código muestra cómo utilizar un YAnimator junto con un elemento Rectangle.

Rectangle {
    id: ymovingBox
    width: 50
    height: 50
    color: "lightsteelblue"
    YAnimator {
        target: ymovingBox;
        from: 10;
        to: 0;
        duration: 1000
        running: true
    }
}

También es posible utilizar la palabra clave « on » para vincular el YAnimator directamente a una instancia de Item.

Rectangle {
    width: 50
    height: 50
    color: "lightsteelblue"
    YAnimator on y {
        from: 10;
        to: 0;
        duration: 1000
    }
}

Nota: Los tiposde animador no aportan ninguna ventaja cuando se utiliza un bucle de renderizado sin subprocesos.

Nota: Se recomienda que las aplicaciones consideren diseños basados en principios multihilo y asíncronos, en lugar de depender de los animadores para mostrar contenido animado mientras se realizan tareas costosas y bloqueantes en el hilo principal (GUI). En lugar de operaciones largas y bloqueantes, es preferible utilizar ` WorkerScript ` y ` asynchronous image loading ` en QML, así como hilos de trabajo, algoritmos paralelos Qt Concurrenty las corrutinas en C++, manteniendo así la capacidad de respuesta de toda la aplicación y la interfaz de usuario en todo momento.

© 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.