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
inline-component-enums.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 Inline component enums
8
\brief [inline-component-enums] An enum was declared inside an inline component.
9
10
\qmllintwarningcategory inline-component-enums
11
12
\section1 Enums declared inside of inline components are ignored
13
14
\section2 What happened?
15
You defined an \l{qtqml-syntax-objectattributes.html#enumeration-attributes}{enum}
16
inside an inline component.
17
18
\section2 Why is this bad?
19
The QML language only allows enum definitions inside the root
20
item of the QML file. Enums declared inside an inline
21
component are unusable, even inside the inline component. The same applies to
22
enums declared inside non-root QML objects.
23
24
\section2 Example
25
\qml
26
import QtQuick
27
28
Item {
29
component MyInlineComponent: Item {
30
enum MyEnum { Hello, World }
31
}
32
}
33
34
\endqml
35
To fix this warning, move the enum declaration into the root element of the
36
QML file:
37
\qml
38
import QtQuick
39
40
Item {
41
enum MyEnum { Hello, World }
42
component MyInlineComponent: Item {
43
}
44
}
45
46
\endqml
47
*/
qtdeclarative
src
qml
doc
src
qmllint
inline-component-enums.qdoc
Generated on
for Qt by
1.16.1