En esta página

Enlaces duplicados

Esta categoría de advertencia se escribe [duplicate-property-binding] por qmllint.

Interceptor duplicado en propiedad

¿Qué ha ocurrido?

Una propiedad tiene múltiples interceptores.

¿Por qué es malo?

El motor QML no admite el establecimiento de varios interceptores en la misma propiedad.

Ejemplo

Usamos Behavior como interceptor dos veces en la misma propiedad:

import QtQuick

Rectangle {
    Behavior on width {
        NumberAnimation { duration: 1000 }
    }
    Behavior on width { // not ok: Duplicate interceptor on property "width" [duplicate-property-binding]
        NumberAnimation { duration: 2000 }
    }
}

Para corregir esta advertencia, elimine todos los interceptores excepto uno Behavior:

import QtQuick

Rectangle {
    Behavior on width {
        NumberAnimation { duration: 2000 }
    }
}

Véase también Tipos de modificadores de propiedades.

Fuente de valor duplicada en una propiedad

¿Qué ocurre?

Una propiedad tiene múltiples fuentes de valor.

¿Por qué es malo?

Las fuentes de valor mostrarán un comportamiento inesperado cuando se combinen. Vea el siguiente ejemplo.

Ejemplo

Usemos NumberAnimation como fuente de valor dos veces en la misma propiedad:

import QtQuick

Rectangle {
    NumberAnimation on x { to: 50; duration: 1000 }
    NumberAnimation on x { to: 10; duration: 100 } // not ok: Duplicate value source on property "x" [duplicate-property-binding]

    onXChanged: console.log(x)
}

Si comprueba la salida de ese programa, verá que los dos NumberAnimation se intercalarán entre sí, lo que probablemente no es el efecto que se pretendía. Para solucionar esta advertencia, elimine todos los NumberAnimation menos uno:

import QtQuick

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

No se puede combinar la fuente de valores y la vinculación

¿Qué ha ocurrido?

Una propiedad tiene una fuente de valor y un enlace en la misma propiedad.

¿Por qué es malo?

La vinculación actualizará el valor de la propiedad antes de que la fuente de valor comience a actualizar esta propiedad. Esto puede conducir a un comportamiento inesperado, y también es más difícil de leer.

Ejemplo

Usemos NumberAnimation como fuente de valor en la misma propiedad:

import QtQuick

Rectangle {
    NumberAnimation on x { to: 50; duration: 1000 } // not ok: Cannot combine value source and binding on property "x" [duplicate-property-binding]
    x: 55

    onXChanged: console.log(x)
}

Si comprueba la salida de ese programa, verá que NumberAnimation se animará de 55 a 50, lo que sería más fácil de leer con el siguiente código:

import QtQuick

Rectangle {
    NumberAnimation on x { from: 55; to: 50; duration: 1000 } // ok: intentions are clearer now!
}

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