Auf dieser Seite

Enum-Eintrag stimmt mit Enum überein

Diese Warnkategorie wird von qmllint als „ [enum-entry-matches-enum] “ bezeichnet.

Der Enum-Eintrag sollte anders benannt sein als die Enum selbst

Was ist passiert?

Eine Enum hat denselben Namen wie einer ihrer Einträge.

Warum ist das schlecht?

Es kann zu Unklarheiten darüber kommen, worauf eine Abfrage verweist; siehe Beispiel unten.

Beispiel

// 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?
}

Um diese Warnung zu beheben, beheben Sie den Namenskonflikt, indem Sie entweder die Enum oder den Enum-Eintrag umbenennen:

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