On this page

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
    }
}

© 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.