이 페이지에서

재귀 깊이 오류

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.