Utilisation de « var » avant la déclaration
Cette catégorie d'avertissement est orthographiée « [var-used-before-declaration] » par qmllint.
La variable est utilisée ici avant sa déclaration
Que s'est-il passé ?
Vous avez utilisé une variable avant de l'avoir déclarée.
Pourquoi est-ce un problème ?
Cela rend le code plus difficile à lire. Les variables déclarées avec ` let ` ou ` const ` généreront une erreur lors de l'exécution.
Exemple
import QtQuick
Item {
function f() {
x = 42; // x is used before its declaration
let x;
}
Component.onCompleted: f()
}Pour corriger cet avertissement, placez la déclaration avant l'utilisation :
import QtQuick
Item {
function f() {
let x;
x = 42;
}
Component.onCompleted: f()
}Voir aussi Expressions JavaScript dans les documents 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.