이 페이지에서

var가 아닌 속성을 선호합니다

qmllint에서는 이 경고 범주를 ' [prefer-non-var-properties] '로 표기합니다.

var보다 더 구체적인 유형을 선호하십시오

무슨 일이 있었나요?

QML에서 int 이나 string 과 같이 더 구체적인 유형 대신 var 유형으로 속성을 정의했습니다.

왜 문제가 될까요?

이는 코드의 가독성에 영향을 미치며, 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.