In questa pagina

Enumerazione dichiarata al di fuori dell'elemento radice

Questa categoria di avviso viene indicata da qmllint con il nome " [non-root-enum] ".

Enumerazione dichiarata al di fuori dell'elemento radice

Cosa è successo?

È stata dichiarata un'enumerazione al di fuori dell'elemento radice del componente.

Perché è un problema?

Non sarà accessibile. L'accesso alle enumerazioni avviene tramite <nome componente>.<nome enumerazione opzionale>.<voce dell'enumerazione>. Se l'enumerazione non si trova alla radice del componente, questa ricerca non funzionerà.

Esempio

// Main.qml
import QtQuick

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

Per risolvere questo avviso, sposta l'enumerazione alla radice 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.