In questa pagina

Maiuscolo/minuscolo della chiave dell'enumerazione

Questa categoria di avviso viene indicata da qmllint come " [enum-key-case] ".

La chiave dell'enumerazione inizia con una lettera minuscola

Cosa è successo?

Un'enumerazione contiene una chiave che inizia con una lettera minuscola.

Perché è un problema?

Può creare ambiguità durante le operazioni di ricerca. Le chiavi delle enumerazioni dovrebbero iniziare con una lettera maiuscola per distinguerle dalle proprietà dei singleton e degli oggetti associati. Il mancato rispetto di questa convenzione può portare a risultati inaspettati.

Esempio

// Properties.qml
import QtQuick

Item {
    enum Color { red, green, blue }
}
// Main.qml
import QtQuick

Item {
    // This lookup could be interpreted as a property lookup on a Singleton or attached object.
    property int i: Properties.green
}

Per risolvere questo avviso, rinominare la chiave in modo che inizi con una lettera maiuscola.

// Properties.qml
import QtQuick

Item {
    enum Color { Red, Green, Blue }
}
// Main.qml
import QtQuick

Item {
    // No ambiguity for the user or the QML engine, this is an enum lookup.
    property int i: Properties.Green
}

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