En esta página

Enum declarado fuera del elemento raíz

Esta categoría de advertencia se escribe [non-root-enum] por qmllint.

Enum declarado fuera del elemento raíz

¿Qué ha ocurrido?

Se ha declarado un enum fuera del elemento raíz del componente.

¿Por qué es malo?

No será accesible. Las sumas se acceden como <nombre del componente>.<nombre opcional de la suma>.<entrada de la suma>. Si el enum no está en la raíz del componente, esta búsqueda no funcionará.

Ejemplo:

// Main.qml
import QtQuick

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

Para corregir esta advertencia, mueva el enum a la raíz del componente:

// Main.qml
import QtQuick

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

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