목록이 아닌 속성
qmllint에서는 이 경고 범주를 ‘ [non-list-property] ’로 표기합니다.
기본값이 지정된 비목록 속성에 여러 객체를 할당할 수 없음
무슨 일이 발생했나요?
기본 속성에 여러 바인딩이 있지만, 기본 속성 유형이 리스트 유형이 아니며 하나의 바인딩만 허용합니다.
왜 문제가 됩니까?
마지막 바인딩을 제외한 기본 속성에 대한 모든 바인딩은 무시됩니다. 이는 기본 속성이 목록이어야 하거나, 동일한 속성에 대한 바인딩이 너무 많다는 것을 시사할 가능성이 높습니다.
예시
리스트가 아닌 기본 속성이 하나 있는 컴포넌트 MyComponent 를 선언하고, 해당 기본 속성에 세 개의 항목을 바인딩해 보겠습니다:
import QtQuick
Item {
component MyComponent: QtObject {
default property Item helloWorld
}
MyComponent {
// first item bound to default property:
Item { objectName: "first" } // will warn: Cannot assign multiple objects to a default non-list property [non-list-property]
// second item bound to default property:
Item { objectName: "second" } // not ok: default property was bound already
// third item bound to default property:
Item { objectName: "third" } // not ok: default property was bound already
Component.onCompleted: console.log(helloWorld.objectName) // prints "third"
}
}이 경고를 해결하려면 기본 속성을 리스트로 바꾸십시오:
import QtQuick
Item {
component MyComponent: QtObject {
default property list<Item> helloWorld
}
MyComponent {
// first item bound to default property:
Item { objectName: "first" } // ok: binding a first item to the list
// second item bound to default property:
Item { objectName: "second" } // ok: binding a second item to the list
// third item bound to default property:
Item { objectName: "third" } // ok: binding a third item to the list
}
}기본 속성이 리스트가 아니어야 하는 경우, 이 경고를 해결하려면 불필요한 바인딩을 모두 제거하십시오:
import QtQuick
Item {
component MyComponent: QtObject {
default property Item helloWorld
}
MyComponent {
Item { objectName: "first" } // ok: just one item bound to default property
}
MyComponent {
Item { objectName: "second" } // ok: just one item bound to default property
}
MyComponent {
Item { objectName: "third" } // ok: just one item bound to default property
}
}© 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.