Inheritance cycle

This warning category is spelled [inheritance-cycle] by qmllint.

Component is part of an inheritance cycle

What happened?

A component inherited directly or indirectly from itself.

Usually, Components can inherit properties, methods, signals and enums from other components.

If a component inherits itself directly or indirectly through another base component, then it forms an inheritance cycle. The warning indicates that the current component is inside an inheritance cycle, see Example.

Why is this bad?

Components with inheritance cycles will not be created at runtime: they will be null instead.

Example

import QtQuick

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

To fix this warning, break up the inheritance cycle:

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{}
}

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