- Qt 6.11
- Qt Qml
- Qt Qml Tooling
- qmllint
- QML Lint Warning and Errors
- Enum declared outside the root element
- Qt 6.11.2 Reference Documentation

Non-list property ◦ Quick: Attached property type

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

Non-list property ◦ Quick: Attached property type