In questa pagina

Voce dell'enumerazione corrisponde a un'altra voce dell'enumerazione

Questa categoria di avviso viene indicata da qmllint come " [enum-entry-matches-enum] ".

La voce dell’enumerazione dovrebbe avere un nome diverso da quello dell’enumerazione stessa

Cosa è successo?

Un enum ha lo stesso nome di una delle sue voci.

Perché è un problema?

Potrebbe esserci ambiguità riguardo al risultato di una ricerca; si veda l'esempio qui sotto.

Esempio

// Main.qml
import QtQuick

Item {
    enum E { A, B, C, D, E }
    property var v: Main.E // Does this refer to the enum or to its entry?
}

Per risolvere questo avviso, risolvi il conflitto di nomi rinominando l'enumerazione o l'elemento dell'enumerazione:

// Main.qml
import QtQuick

Item {
    enum Enum { A, B, C, D, E }
    property var v: Main.E // v contains Enum.E. No more ambiguity is possible
}

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