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