열거형은 타입이 아닙니다
qmllint에서는 이 경고 범주를 ‘ [enums-are-not-types] ’로 표기합니다.
QML 열거형은 타입이 아닙니다
무슨 일이 있었나요?
유형 어노테이션 내에서 열거형 이름을 사용했습니다.
왜 문제가 될까요?
열거형 이름은 타입이 아니므로 타입 어노테이션에서 사용할 수 없습니다. QML 툴링은 이 타입 어노테이션을 사용할 수 없습니다. 컴파일러는 이 메서드를 C++로 컴파일할 수 없으며, qmllint와 QML Language Server 이 메서드를 분석할 수 없습니다.
예시
// Main.qml
import QtQuick
Item {
enum HelloWorld { Hello, World }
function f(e: Main.HelloWorld): bool {
return e == World
}
}이 경고를 해결하려면, 타입 어노테이션 내의 열거형 이름을 기본 타입으로 대체하십시오. 예를 들어, 기본 타입이 최대 32비트를 필요로 하는 경우 ` int `로, 그렇지 않은 경우 ` double`로 변경하십시오.
import QtQuick
Item {
enum HelloWorld { Hello, World }
function f(e: int): bool {
return e === World
}
}© 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.