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
missing-enum-entry.qdoc
Go to the documentation of this file.
1// Copyright (C) 2023 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-missing-enum-entry.html
6\ingroup qmllint-warnings-and-errors
7
8\title Missing enum entry
9\brief [missing-enum-entry] Enum value is missing from its declaration.
10
11\qmllintwarningcategory missing-enum-entry
12
13\section1 Is not an entry of enum
14
15\section2 What happened?
16You used an enum value that does not exist.
17
18\section2 Why is this bad?
19The enum value will be undefined at runtime.
20
21\section2 Example
22\qml
23// Main.qml
24import QtQuick
25
26Item {
27 enum Hello { World }
28
29 Component.onCompleted: function() {
30 console.log(Main.Hello.Wordl, Main.Hello.Moon) // both Wordl and Moon are incorrect
31 }
32}
33
34\endqml
35To fix this warning, correct a potential typo or add the missing enum value
36to the definition:
37\qml
38// Main.qml
39import QtQuick
40
41Item {
42 enum Hello { World, Moon }
43
44 Component.onCompleted: function() {
45 console.log(Main.Hello.World, Main.Hello.Moon) // both correct now
46 }
47}
48\endqml
49*/