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