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-key-case.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 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 key case
8\brief [enum-key-case] Enum key starts with a lowercase letter.
9
10\qmllintwarningcategory enum-key-case
11
12\section1 Enum key starts with a lowercase letter
13
14\section2 What happened?
15An enum contains a key starting with a lowercase letter.
16
17\section2 Why is that bad?
18It can create ambiguity when performing lookups. Enum keys should start with an uppercase letter
19to distinguish them from properties of singletons and attached objects. Not following this
20convention can lead to unexpected results.
21
22\section2 Example
23\qml
24// Properties.qml
25import QtQuick
26
27Item {
28 enum Color { red, green, blue }
29}
30\endqml
31\qml
32// Main.qml
33import QtQuick
34
35Item {
36 // This lookup could be interpreted as a property lookup on a Singleton or attached object.
37 property int i: Properties.green
38}
39\endqml
40
41To fix this warning, rename the key so it starts with an uppercase letter.
42
43\qml
44// Properties.qml
45import QtQuick
46
47Item {
48 enum Color { Red, Green, Blue }
49}
50\endqml
51\qml
52// Main.qml
53import QtQuick
54
55Item {
56 // No ambiguity for the user or the QML engine, this is an enum lookup.
57 property int i: Properties.Green
58}
59\endqml
60*/