En esta página

Función utilizada antes de su declaración

Esta categoría de advertencia se escribe [function-used-before-declaration] por qmllint.

Esta categoría está desactivada por defecto.

Función utilizada antes de su declaración

¿Qué ha ocurrido?

Llamaste a una función o usaste su nombre antes de que la función fuera declarada.

¿Por qué es malo?

Hace que el código sea más difícil de leer y puede causar confusión.

Tenga en cuenta que la función está disponible antes de su declaración debido a la elevación.

Ejemplo

import QtQuick

Item {
    function f() {
        g(42)
        function g() { return 42; }
    }
}

Para arreglar esta advertencia, mueva la declaración antes del uso.

import QtQuick

Item {
    function f() {
        function g() { return 42; }
        g(42)
    }
}

© 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.