Enums sind keine Typen
Diese Warnkategorie wird von qmllint als „ [enums-are-not-types] “ bezeichnet.
QML-Enumerationen sind keine Typen
Was ist passiert?
Sie haben einen Enum-Namen innerhalb einer Typ-Annotation verwendet.
Warum ist das ein Problem?
Ein Enum-Name ist kein Typ und kann daher nicht in einer Typ-Annotation verwendet werden. QML-Tools können die Typ-Annotation nicht verarbeiten: Der Compiler kann diese Methode nicht in C++ kompilieren, und weder qmllint noch QML Language Server 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 Typannotation durch den zugrunde liegenden Typ, beispielsweise „ int “, wenn der zugrunde liegende Typ höchstens 32 Bit benötigt, oder andernfalls „ double “, um nur ein Beispiel zu nennen.
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.