In questa pagina

Ciclo di ereditarietà

Questa categoria di avviso viene indicata da qmllint con il nome " [inheritance-cycle] ".

Il componente fa parte di un ciclo di ereditarietà

Cosa è successo?

Un componente ha ereditato, direttamente o indirettamente, da se stesso.

Di norma, i componenti possono ereditare proprietà, metodi, segnali ed enumerazioni da altri componenti.

Se un componente eredita da se stesso, direttamente o indirettamente tramite un altro componente di base, si forma un ciclo di ereditarietà. L'avviso indica che il componente corrente si trova all'interno di un ciclo di ereditarietà; si veda l'esempio.

Perché è un problema?

I componenti con cicli di ereditarietà non verranno creati in fase di esecuzione: risulteranno invece null.

Esempio

import QtQuick

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

Per risolvere questo avviso, interrompere il ciclo di ereditarietà:

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.