En esta página

UniformAnimator QML Type

El tipo UniformAnimator anima un uniforme de un ShaderEffect. Más...

Import Statement: import QtQuick
Inherits:

Animator

Propiedades

Descripción detallada

Animator son diferentes de los tipos de Animación normales. Cuando se utiliza un Animator, la animación puede ejecutarse en el hilo de renderizado y el valor de la propiedad saltará al final cuando la animación haya terminado.

El valor de la propiedad QML que define el uniforme se actualiza una vez finalizada la animación.

El siguiente fragmento muestra cómo utilizar un UniformAnimator junto con un elemento ShaderEffect.

ShaderEffect {
    id: shader
    width: 50
    height: 50
    property variant t;
    UniformAnimator {
        target: shader
        uniform: "t"
        from: 0
        to: 1
        duration: 1000
        running: true
    }
    fragmentShader: "qrc:shader.frag.qsb"
}

También es posible utilizar la palabra clave on para vincular el UniformAnimator directamente a un uniforme de una instancia ShaderEffect.

ShaderEffect {
    width: 50
    height: 50
    property variant t;
    UniformAnimator on t {
        from: 0
        to: 1
        duration: 1000
    }
    fragmentShader: "qrc:shader.frag.qsb"
}

Nota: Los tipos de Animator no tienen ningún beneficio cuando se utiliza un bucle de renderizado no roscado.

Nota: Se recomienda que las aplicaciones consideren diseños basados en principios multihilo y asíncronos, en lugar de confiar en Animators para mostrar contenido animado mientras se realiza un trabajo costoso y bloqueante en el hilo principal (GUI). En lugar de operaciones largas y bloqueantes, prefiera utilizar WorkerScript y asynchronous image loading en QML, e hilos de trabajo, algoritmos paralelos, Qt Concurrenty coroutines en C++, manteniendo así toda la aplicación y la interfaz de usuario receptiva todo el tiempo.

Véase también ShaderEffect y ShaderEffectSource.

Documentación de propiedades

uniform : string

Esta propiedad contiene el nombre del uniforme a animar.

El valor del uniforme debe corresponder tanto a una propiedad en el destino ShaderEffect y debe ser un uniforme de tipo float en el fragment o vertex shader.

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