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
type-instantiated-recursively.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2026 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 Type is instantiated recursively
8
\brief [type-instantiated-recursively] Type instantiates itself.
9
10
\qmllintwarningcategory type-instantiated-recursively
11
12
\section1 Type can't be instantiated recursively
13
14
\section2 What happened?
15
A component instantiated itself.
16
17
\section2 Why is this bad?
18
The component needs itself to instantiate itself, creating an infinite loop. The QML runtime
19
will error out on this component.
20
21
\section2 Example
22
\qml
23
// MyComponent.qml
24
import QtQuick
25
26
Item {
27
MyComponent {}
28
}
29
\endqml
30
To fix this warning,
31
\list
32
\li Replace the problematic component with another one if it was a mistake.
33
\li Postpone the instantiation to later, with
34
\l{Dynamic QML Object Creation from JavaScript} for example.
35
\endlist
36
\qml
37
// MyComponent.qml
38
import QtQuick
39
40
Item {
41
// solution 1: MyComponent was not needed here, use another type
42
Item {}
43
44
// solution 2: add a MyComponent property and set it later
45
property MyComponent myChild
46
}
47
\endqml
48
*/
qtdeclarative
src
qml
doc
src
qmllint
type-instantiated-recursively.qdoc
Generated on
for Qt by
1.16.1