Funktion vor ihrer Deklaration verwendet
Diese Warnkategorie wird von qmllint als „ [function-used-before-declaration] “ bezeichnet.
Diese Kategorie ist standardmäßig deaktiviert.
Verwendung einer Funktion vor ihrer Deklaration
Was ist passiert?
Sie haben eine Funktion aufgerufen oder deren Namen verwendet, bevor die Funktion deklariert wurde.
Warum ist das schlecht?
Es erschwert das Lesen des Codes und kann zu Verwirrung führen.
Beachten Sie, dass die Funktion aufgrund des Hoisting bereits vor ihrer Deklaration verfügbar ist.
Beispiel
import QtQuick
Item {
function f() {
g(42)
function g() { return 42; }
}
}Um diese Warnung zu beheben, verschieben Sie die Deklaration vor die Verwendung.
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.