制限タイプ

この警告カテゴリーはqmllintによって[restricted-type]

ここからスコープされていない列挙型にアクセスすることはできません。

何が起こったのでしょうか?

C++で定義されたenumの値にenum型名でアクセスしました。

これはなぜ悪いのでしょうか?

C++で定義されたスコープされていない列挙型は、その列挙型名ではアクセスできません。それらは実行時に未定義になります。

import QtQuick
import SomeModule // contains MyClass

Item {
    property int i: MyClass.Hello.World
}

ここでMyClassは

class MyClass: public QObject
{
    Q_OBJECT
    QML_ELEMENT

public:
    enum Hello { World };
    Q_ENUM(Hello);
    ...

};

この警告を修正するには、QML の使用法から不要な列挙型名を削除してください:

import QtQuick

Item {
    property int i: MyClass.World
}

もしあなたが列挙型の作者であれば、QML のコードを変更する代わりに、列挙型の定義を変更して列挙型クラスを使用することもできます:

class MyClass: public QObject
{
    Q_OBJECT
    QML_ELEMENT

public:
    enum class Hello { World };
    Q_ENUM(Hello);
    ...
};

Note: enum型の登録についての詳細は、こちらを参照してください。

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