Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 A component inherits from itself.
10
11\section1 Component Is Part Of An Inheritance Cycle
12
13\section2 What happened?
14A component inherited directly or indirectly from itself.
15
16Usually, Components can inherit properties, methods, signals and enums from other components.
17
18If a component inherits itself directly or indirectly through another base component, then
19it forms an inheritance cycle. The warning indicates that the current component is inside an
20inheritance cycle, see \l{#example}{Example}.
21
22\section2 Why is this bad?
23Components with inheritance cycles will not be created at runtime: they will be null instead.
24
25\section2 Example
26\qml
27import QtQuick
28
29Item {
30 component Cycle: Cycle {} // not ok: directly inherits from itself
31 component C: C2 {} // not ok: indirectly inherits from itself
32 component C2: C{}
33}
34\endqml
35You can fix this warning by breaking up the inheritance cycle
36\qml
37import QtQuick
38
39Item {
40 component Cycle: Item {} // ok: does not inherit from itself
41 component C: C2 {} // ok: does not indirectly inherits from itself anymore
42 component C2: Cycle{}
43}
44\endqml
45*/
46