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
\page qmllint-warnings-and-errors-enum-entry-matches-enum.html
6
\ingroup qmllint-warnings-and-errors
7
8
\title Enum entry matches enum
9
\brief [enum-entry-matches-enum] Enum entry should be named differently than the enum itself.
10
11
\qmllintwarningcategory enum-entry-matches-enum
12
13
\section1 Enum entry should be named differently than the enum itself
14
15
\section2 What happened?
16
An enum has the same name as one of its entries.
17
18
\section2 Why is that bad?
19
There can be ambiguity as to what a lookup resolves to, see example below.
20
21
\section2 Example
22
\qml
23
// Main.qml
24
import QtQuick
25
26
Item {
27
enum E { A, B, C, D, E }
28
property var v: Main.E // Does this refer to the enum or to its entry?
29
}
30
\endqml
31
To fix this warning, resolve the name clash by renaming either the enum or the
32
enum entry:
33
\qml
34
// Main.qml
35
import QtQuick
36
37
Item {
38
enum Enum { A, B, C, D, E }
39
property var v: Main.E // v contains Enum.E. No more ambiguity is possible
40
}
41
\endqml
42
*/
qtdeclarative
src
qml
doc
src
qmllint
enum-entry-matches-enum.qdoc
Generated on
for Qt by
1.14.0