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