Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
enum-entry-matches-enum.qdoc
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\ingroup qmllint-warnings-and-errors
6
7\title Enum entry matches enum
8\brief [enum-entry-matches-enum] Enum entry should be named differently than the enum itself.
9
10\qmllintwarningcategory enum-entry-matches-enum
11
12\section1 Enum entry should be named differently than the enum itself
13
14\section2 What happened?
15An enum has the same name as one of its entries.
16
17\section2 Why is that bad?
18There can be ambiguity as to what a lookup resolves to, see example below.
19
20\section2 Example
21\qml
22// Main.qml
23import QtQuick
24
25Item {
26 enum E { A, B, C, D, E }
27 property var v: Main.E // Does this refer to the enum or to its entry?
28}
29\endqml
30To fix this warning, resolve the name clash by renaming either the enum or the
31enum entry:
32\qml
33// Main.qml
34import QtQuick
35
36Item {
37 enum Enum { A, B, C, D, E }
38 property var v: Main.E // v contains Enum.E. No more ambiguity is possible
39}
40\endqml
41*/