このページでは

再帰深さのエラー

この警告カテゴリは、qmllint によって「[recursion-depth-errors] 」と表記されます。

文または式の最大深さを超えました

何が起きたのか?

QML の文または式が、コンパイラにとってネストが深すぎました。これは通常、生成されたコードで文や式が非常に長くなる場合にのみ発生します。再帰の制限は、通常、妥当な QML ドキュメントであれば十分大きい値に設定されているためです。

なぜ問題なのか?

QML エンジンはこのコードを実行できなくなります。

例

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
}

この警告を解消するには、コードを小さな単位に自動生成してください。深くネストされたコンポーネントを複数のファイルに分割するか、インラインコンポーネントとして記述するか、あるいは深くネストされた式を複数の式に分割してください:

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.