このページでは

インラインコンポーネントの列挙型

この警告カテゴリは、qmllint では「[inline-component-enums] 」と表記されます。

インラインコンポーネント内で宣言された列挙型は無視されます

何が起きたのか?

インラインコンポーネント内で列挙型を定義しました。

なぜ問題なのでしょうか?

QML 言語では、QML ファイルのルートアイテム内でのみ enum 定義が許可されています。インラインコンポーネント内で宣言された enum は、そのインラインコンポーネント内であっても使用できません。ルート以外の QML オブジェクト内で宣言された enum についても同様です。

例

import QtQuick

Item {
    component MyInlineComponent: Item {
        enum MyEnum { Hello, World }
    }
}

この警告を解消するには、列挙型の宣言をQMLファイルのルート要素に移動してください:

import QtQuick

Item {
    enum MyEnum { Hello, World }
    component MyInlineComponent: Item {
    }
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.