- Qt 6.11
- Qt Qml
- QML Lint Warning and Errors
- Enums are not types
- Qt 6.11.1 Reference Documentation

# Enums are not types

This warning category is spelled `[enums-are-not-types]` by qmllint.

## QML enumerations are not types

### What happened?

You used an enum name inside a type annotation.

### Why is that bad?

An enum name is not a type and therefore can't be used in a type annotation. QML tooling is not able to use the type annotation: the compiler can't compile this method to C++ and qmllint as well as QML Language Server can't analyze this method.

### Example

     // Main.qml
     import QtQuick

     Item {
         enum HelloWorld { Hello, World }
         function f(e: Main.HelloWorld): bool {
             return e == World
         }
     }

To fix this warning, replace the enum name in the type annotation with the underlying type, like `int` if the underlying type needs at most 32 bit, or otherwise `double`, for example.

     import QtQuick

     Item {
         enum HelloWorld { Hello, World }
         function f(e: int): bool {
             return e === World
         }
     }