이 페이지에서

제한된 유형

qmllint에서는 이 경고 범주를 ‘ [restricted-type] ’로 표기합니다.

여기서는 스코프가 지정되지 않은 열거형에 접근할 수 없습니다

무슨 일이 발생했나요?

C++에서 정의된 열거형의 값을 열거형 유형 이름으로 참조했습니다.

왜 문제가 될까요?

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);
    ...
};

참고: 열거형 타입 등록에 대한 자세한 정보는 여기에서 확인할 수있습니다 .

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