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?
15You defined an \l{qtqml-syntax-objectattributes.html#enumeration-attributes}{enum}
16inside an inline component.
17
18\section2 Why is this bad?
19The QML language only allows enum definitions inside the root
20item of the QML file. Enums declared inside an inline
21component are unusable, even inside the inline component. The same applies to
22enums declared inside non-root QML objects.
23
24\section2 Example
25\qml
26import QtQuick
27
28Item {
29 component MyInlineComponent: Item {
30 enum MyEnum { Hello, World }
31 }
32}
33
34\endqml
35To fix this warning, move the enum declaration into the root element of the
36QML file:
37\qml
38import QtQuick
39
40Item {
41 enum MyEnum { Hello, World }
42 component MyInlineComponent: Item {
43 }
44}
45
46\endqml
47*/