이 페이지에서

의도하지 않은 빈 블록

qmllint에서는 이 경고 범주를 ' [unintentional-empty-block] '으로 표기합니다.

의도하지 않은 빈 블록

무슨 일이 발생했나요?

속성 바인딩의 표현식으로 빈 블록이 선언되었습니다.

아마도 빈 객체 리터럴을 선언하려고 했을 것입니다. 이를 위해서는 리터럴을 괄호로 묶어야 합니다. 이는 리터럴을 빈 블록과 명확히 구분하기 위해 필요합니다.

왜 문제가 될까요?

명령문이 없는 블록을 속성 바인딩으로 할당하면 아무런 동작도 발생하지 않으며, 독자를 혼란스럽게 할 수 있습니다. 해당 바인딩을 평가할 때 어떤 명령문도 실행되지 않으며, 바인딩 결과는 undefined로 평가됩니다.

예시

import QtQml

QtObject {
    property var v: {} // This is not an empty object literal!
}

이 경고를 해결하려면 객체 리터럴을 괄호로 감싸거나, 바인딩을 아예 제거하십시오:

import QtQml

QtObject {
    property var v: ({}) // This is an empty object literal
}

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