이 페이지에서

열거형은 타입이 아닙니다.

이 경고 범주의 철자는 [enums-are-not-types] 입니다.

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.