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