Enum entry matches enum

This warning category is spelled [enum-entry-matches-enum] by qmllint.

Enum entry should be named differently than the enum itself

What happened?

An enum has the same name as one of its entries.

Why is that bad?

There can be ambiguity as to what a lookup resolves to, see example below.

Example

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

To fix this warning, resolve the name clash by renaming either the enum or the enum entry:

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

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