목록에 없는 속성
이 경고 범주의 철자는 [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 } }
© 2025 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.