Auf dieser Seite

Fehler bei der Rekursionstiefe

Diese Warnkategorie wird von qmllint als „ [recursion-depth-errors] “ bezeichnet.

Maximale Anweisungs- oder Ausdrucks-Tiefe überschritten

Was ist passiert?

Eine QML-Anweisung oder ein Ausdruck war für den Compiler zu tief verschachtelt. Dies tritt in der Regel nur bei generiertem Code auf, bei dem Anweisungen oder Ausdrücke sehr lang sein können, da die Rekursionsgrenze für jedes sinnvolle QML-Dokument normalerweise groß genug ist.

Warum ist das ein Problem?

Die QML-Engine kann diesen Code nicht ausführen.

Beispiel

import QtQuick

Item {
    function f() {
        let x = 1 + 1 + .... + 1 // maximum depth exceeded: add too many ones together
        return x
    }

    Item { Item { .... } } // maximum depth exceeded: too many nested Item's
}

Um diese Warnung zu beheben, generieren Sie automatisch kleinere Codeabschnitte. Teilen Sie tief verschachtelte Komponenten auf mehrere Dateien oder Inline-Komponenten auf, oder teilen Sie tief verschachtelte Ausdrücke in mehrere Ausdrücke auf:

import QtQuick

Item {
    function f() {
        let x = 1 + 1 + .... + 1 // first half of the split
        x += 1 + 1 + .... + 1 // second half of the split
        return x
    }

    component NestedItem : Item { Item {... }} // first half of the nested Item
    component DeeplyNestedItem: Item { ... NestedItem{} ... } // second half of the nested Items + NestedItem
    DeeplyNestedItem {}
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.