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
recursion-depth-errors.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 Recursion depths errors
8
\brief [recursion-depth-errors] Qml statement or expression is too deeply nested.
9
10
\qmllintwarningcategory recursion-depth-errors
11
12
\section1 Maximum statement or expression depth exceeded
13
\section2 What happened?
14
A QML statement or expression was too deeply nested for the compiler. This usually only happens for
15
generated code where statements or expressions can be very long, as the recursion limit is usually
16
large enough for any sensible QML document.
17
18
\section2 Why is this bad?
19
The QML engine will not be able to run this code.
20
21
\section2 Example
22
\qml
23
import QtQuick
24
25
Item {
26
function f() {
27
let x = 1 + 1 + .... + 1 // maximum depth exceeded: add too many ones together
28
return x
29
}
30
31
Item { Item { .... } } // maximum depth exceeded: too many nested Item's
32
}
33
\endqml
34
35
To fix this warning, auto-generate smaller code pieces. Split deeply nested
36
Components in multiple files or inline components, or split deeply nested
37
expressions into multiple expressions:
38
\qml
39
import QtQuick
40
41
Item {
42
function f() {
43
let x = 1 + 1 + .... + 1 // first half of the split
44
x += 1 + 1 + .... + 1 // second half of the split
45
return x
46
}
47
48
component NestedItem : Item { Item {... }} // first half of the nested Item
49
component DeeplyNestedItem: Item { ... NestedItem{} ... } // second half of the nested Items + NestedItem
50
DeeplyNestedItem {}
51
}
52
\endqml
53
*/
qtdeclarative
src
qml
doc
src
qmllint
recursion-depth-errors.qdoc
Generated on
for Qt by
1.16.1