En esta página

Ciclo de herencia

Esta categoría de advertencia se escribe [inheritance-cycle] por qmllint.

El componente forma parte de un ciclo de herencia

¿Qué ha ocurrido?

Un componente hereda directa o indirectamente de sí mismo.

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

Si un componente se hereda a sí mismo directa o indirectamente a través de otro componente base, entonces forma un ciclo de herencia. La advertencia indica que el componente actual está dentro de un ciclo de herencia, ver Ejemplo.

¿Por qué es malo?

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 corregir esta advertencia, rompa 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.