En esta página

Ciclo de alias

qmllint escribe esta categoría de advertencia como « [alias-cycle] ».

La propiedad alias forma parte de un ciclo de alias

¿Qué ha pasado?

Un alias de propiedad apunta a sí mismo o a otro alias que, a su vez, apunta a sí mismo.

Normalmente, un alias de propiedad debería hacer referencia a otra propiedad, ya sea directamente o indirectamente, pasando por otra propiedad alias.

Si un alias de propiedad hace referencia a sí mismo, ya sea directa o indirectamente, se forma un ciclo de alias. La advertencia indica que la propiedad alias actual se encuentra dentro de un ciclo de alias o hace referencia a él; véase el ejemplo.

¿Por qué es un problema?

Las instancias de componentes con ciclos de alias no se crearán en tiempo de ejecución: en su lugar, serán nulas.

Ejemplo

import QtQuick

Item {
    id: someId
    property alias myself: someId.myself // not ok: referring to itself

    property alias cycle: someId.cycle2 // not ok: indirectly referring to itself
    property alias cycle2: someId.cycle

    property alias indirect: someId.cycle // not ok: referring to alias indirectly referring to itself
}

Para solucionar esta advertencia, rompe los ciclos de alias:

import QtQuick

Item {
    id: someId
    Item {
        id: anotherId
        property string myself
        property int cycle
    }
    property alias myself: anotherId.myself // ok: referring to a property

    property alias cycle: someId.cycle2 // ok: does not refer to itself anymore
    property alias cycle2: anotherId.cycle // ok: not a cycle anymore

    property alias indirect: someId.cycle // ok: cycle does not form an alias cycle anymore
}

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