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

この警告カテゴリーはqmllintによって[non-root-enum]

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

何が起こりましたか?

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
    }
}

© 2025 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.