このページでは

ルート要素の外で宣言された列挙型

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

ルート要素の外で宣言された列挙型

何が起きたのか?

コンポーネントのルート要素の外側で列挙型が宣言されました。

なぜ問題なのか?

アクセスできなくなります。列挙型へのアクセスは、<コンポーネント名>.<オプションの列挙型名>.<列挙型エントリ> の形式で行われます。列挙型がコンポーネントのルートにない場合、この検索は機能しません。

例

// Main.qml
import QtQuick

Item {
    Item {
        id: item
        enum Color { Red, Green, Blue }
    }
}

この警告を解消するには、列挙型をコンポーネントのルートに移動してください:

// Main.qml
import QtQuick

Item {
    enum Color { Red, Green, Blue } // Accessible in Main.qml but also from other files
    Item {
        id: 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.