Enums sind keine Typen
Diese Warnkategorie wird [enums-are-not-types] von qmllint geschrieben.
QML-Aufzählungen sind keine Typen
Was ist passiert?
Sie haben einen Enum-Namen innerhalb einer Type-Annotation verwendet.
Warum ist das schlecht?
Ein Enum-Name ist kein Typ und kann daher nicht in einer Typ-Annotation verwendet werden. Das QML-Tooling ist nicht in der Lage, die Type-Annotation zu verwenden: Der Compiler kann diese Methode nicht nach C++ kompilieren und qmllint sowie QML Language Server können diese Methode nicht analysieren.
Beispiel
// Main.qml import QtQuick Item { enum HelloWorld { Hello, World } function f(e: Main.HelloWorld): bool { return e == World } }
Um diese Warnung zu beheben, ersetzen Sie den Enum-Namen in der Type-Annotation durch den zugrundeliegenden Typ, z.B. int, wenn der zugrundeliegende Typ höchstens 32 Bit benötigt, oder sonst double.
import QtQuick Item { enum HelloWorld { Hello, World } function f(e: int): bool { return e === World } }
© 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.