Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
inheritance-cycle.qdoc
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qmllint-warnings-and-errors-inheritance-cycle.html
6\ingroup qmllint-warnings-and-errors
7
8\title Inheritance cycle
9\brief [inheritance-cycle] A component inherits from itself.
10
11\qmllintwarningcategory inheritance-cycle
12
13\section1 Component is part of an inheritance cycle
14
15\section2 What happened?
16A component inherited directly or indirectly from itself.
17
18Usually, Components can inherit properties, methods, signals and enums from other components.
19
20If a component inherits itself directly or indirectly through another base component, then
21it forms an inheritance cycle. The warning indicates that the current component is inside an
22inheritance cycle, see \l{#example}{Example}.
23
24\section2 Why is this bad?
25Components with inheritance cycles will not be created at runtime: they will be null instead.
26
27\section2 Example
28\qml
29import QtQuick
30
31Item {
32 component Cycle: Cycle {} // not ok: directly inherits from itself
33 component C: C2 {} // not ok: indirectly inherits from itself
34 component C2: C{}
35}
36\endqml
37To fix this warning, break up the inheritance cycle:
38\qml
39import QtQuick
40
41Item {
42 component Cycle: Item {} // ok: does not inherit from itself
43 component C: C2 {} // ok: does not indirectly inherits from itself anymore
44 component C2: Cycle{}
45}
46\endqml
47*/