En esta página

Ciclo de herencia

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

El componente forma parte de un ciclo de herencia

¿Qué ha ocurrido?

Un componente ha heredado, directa o indirectamente, de sí mismo.

Normalmente, los componentes pueden heredar propiedades, métodos, señales y enumeraciones de otros componentes.

Si un componente se hereda a sí mismo, ya sea de forma directa o indirecta a través de otro componente base, se forma un ciclo de herencia. La advertencia indica que el componente actual se encuentra dentro de un ciclo de herencia; véase el ejemplo.

¿Por qué es esto un problema?

Los componentes con ciclos de herencia no se crearán en tiempo de ejecución: en su lugar, serán nulos.

Ejemplo

import QtQuick

Item {
    component Cycle: Cycle {} // not ok: directly inherits from itself
    component C: C2 {}        // not ok: indirectly inherits from itself
    component C2: C{}
}

Para solucionar esta advertencia, rompe el ciclo de herencia:

import QtQuick

Item {
    component Cycle: Item {}  // ok: does not inherit from itself
    component C: C2 {}        // ok: does not indirectly inherits from itself anymore
    component C2: Cycle{}
}

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