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
\ingroup qmllint-warnings-and-errors
6
7
\title Inheritance cycle
8
\brief [inheritance-cycle] A component inherits from itself.
9
10
\qmllintwarningcategory inheritance-cycle
11
12
\section1 Component is part of an inheritance cycle
13
14
\section2 What happened?
15
A component inherited directly or indirectly from itself.
16
17
Usually, Components can inherit properties, methods, signals and enums from other components.
18
19
If a component inherits itself directly or indirectly through another base component, then
20
it forms an inheritance cycle. The warning indicates that the current component is inside an
21
inheritance cycle, see \l{#example}{Example}.
22
23
\section2 Why is this bad?
24
Components with inheritance cycles will not be created at runtime: they will be null instead.
25
26
\section2 Example
27
\qml
28
import QtQuick
29
30
Item {
31
component Cycle: Cycle {} // not ok: directly inherits from itself
32
component C: C2 {} // not ok: indirectly inherits from itself
33
component C2: C{}
34
}
35
\endqml
36
To fix this warning, break up the inheritance cycle:
37
\qml
38
import QtQuick
39
40
Item {
41
component Cycle: Item {} // ok: does not inherit from itself
42
component C: C2 {} // ok: does not indirectly inherits from itself anymore
43
component C2: Cycle{}
44
}
45
\endqml
46
*/
qtdeclarative
src
qml
doc
src
qmllint
inheritance-cycle.qdoc
Generated on
for Qt by
1.16.1