이 페이지에서

열거형 키 대소문자

qmllint에서는 이 경고 범주를 ' [enum-key-case] '로 표기합니다.

열거형 키가 소문자로 시작함

무슨 일이 발생했나요?

열거형에 소문자로 시작하는 키가 포함되어 있습니다.

왜 문제가 될까요?

조회를 수행할 때 모호성이 발생할 수 있습니다. 열거형 키는 싱글톤 및 연결된 객체의 속성과 구별하기 위해 대문자로 시작해야 합니다. 이 규칙을 따르지 않으면 예상치 못한 결과가 발생할 수 있습니다.

예시

// Properties.qml
import QtQuick

Item {
    enum Color { red, green, blue }
}
// Main.qml
import QtQuick

Item {
    // This lookup could be interpreted as a property lookup on a Singleton or attached object.
    property int i: Properties.green
}

이 경고를 해결하려면 키 이름을 대문자로 시작하도록 변경하십시오.

// Properties.qml
import QtQuick

Item {
    enum Color { Red, Green, Blue }
}
// Main.qml
import QtQuick

Item {
    // No ambiguity for the user or the QML engine, this is an enum lookup.
    property int i: Properties.Green
}

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