Enum declared outside the root element

This warning category is spelled [non-root-enum] by qmllint.

Enum declared outside the root element

What happened?

An enum was declared outside of the root element of the component.

Why is that bad?

It won't be accessible. Enums are accessed as <component name>.<optional enum name>.<enum entry>. If the enum is not at the root of the component, this lookup won't work.

Example

// Main.qml
import QtQuick

Item {
    Item {
        id: item
        enum Color { Red, Green, Blue }
    }
}

To fix this warning, move the enum to the root of the component:

// Main.qml
import QtQuick

Item {
    enum Color { Red, Green, Blue } // Accessible in Main.qml but also from other files
    Item {
        id: item
    }
}

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