Var usado antes de la declaración
Esta categoría de advertencia se escribe [var-used-before-declaration] por qmllint.
Aquí se utiliza una variable antes de su declaración
¿Qué ha ocurrido?
Ha utilizado una variable antes de declararla.
¿Por qué es malo?
Esto hace que el código sea más difícil de leer. Las variables declaradas con let o const darán error en tiempo de ejecución.
Ejemplo
import QtQuick Item { function f() { x = 42; // x is used before its declaration let x; } Component.onCompleted: f() }
Para corregir esta advertencia, mueve la declaración antes del uso:
import QtQuick Item { function f() { let x; x = 42; } Component.onCompleted: f() }
Véase también Expresiones JavaScript en documentos QML.
© 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.