Auf dieser Seite

Enum-Eintrag entspricht enum

Diese Warnungskategorie wird von qmllint [enum-entry-matches-enum] buchstabiert.

Der Enum-Eintrag sollte anders benannt werden als das Enum selbst

Was ist passiert?

Eine Enum hat den gleichen Namen wie einer ihrer Einträge.

Warum ist das schlecht?

Es kann mehrdeutig sein, was ein Lookup auflöst, 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, lösen Sie den Namenskonflikt auf, 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.