En esta página

Errores de profundidad de recursión

Esta categoría de advertencia se escribe [recursion-depth-errors] por qmllint.

Se ha superado la profundidad máxima de expresión o sentencia

¿Qué ha ocurrido?

Una sentencia o expresión QML estaba demasiado anidada para el compilador. Esto sólo suele ocurrir en código generado en el que las sentencias o expresiones pueden ser muy largas, ya que el límite de recursión suele ser lo suficientemente grande para cualquier documento QML sensato.

¿Por qué es malo?

El motor QML no podrá ejecutar este código.

Ejemplo

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
}

Para solucionar esta advertencia, autogenere trozos de código más pequeños. Divida Componentes profundamente anidados en múltiples archivos o componentes inline, o divida expresiones profundamente anidadas en múltiples expresiones:

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.