이 페이지에서

변수가 아닌 속성 선호

이 경고 카테고리의 철자는 [prefer-non-var-properties] 입니다.

var보다 더 구체적인 유형 선호

무슨 일이 있었나요?

예를 들어 int 또는 string 같은 보다 구체적인 유형 대신 var 유형으로 QML에서 속성을 정의했습니다.

이것이 왜 나쁜가요?

이는 코드의 가독성에 영향을 미치며 QML 툴링이 특정 유형 최적화를 적용할 수 없습니다.

항상 같은 유형을 보유하는 속성의 속성 유형으로 var 을 사용하지 않아야 합니다. 오탐을 방지하기 위해 qmllint는 단순한 바인딩이 있는 읽기 전용 속성에 대해서만 경고를 표시합니다. 다른 경우에는 여러 유형을 보유해야 하므로 var여야 하는 속성과 항상 같은 유형을 보유하는 속성을 구별하지 못할 수 있습니다.

예시

import QtQuick

Item {
    readonly property var myP: 42
}

이 경고를 수정하려면 var 을 특정 유형으로 바꾸세요.

import QtQuick

Item {
    readonly property int myP: 42
}

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