Propiedad no listada
Esta categoría de advertencia se escribe [non-list-property] por qmllint.
No se pueden asignar varios objetos a una propiedad no de lista predeterminada
¿Qué ocurre?
Una propiedad por defecto tiene múltiples vinculaciones pero el tipo de propiedad por defecto no es un tipo lista y sólo espera una vinculación.
¿Por qué?
Todos los enlaces a la propiedad por defecto, excepto el último, serán ignorados. Esto probablemente indica que la propiedad por defecto debería ser una lista, o que hay demasiados enlaces a la misma propiedad.
Ejemplo
Vamos a declarar un componente MyComponent que tiene una propiedad por defecto que no es una lista, y luego vamos a vincular tres elementos a esa propiedad por defecto:
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" } }
Para solucionar este problema, sustituya la propiedad por defecto por una lista:
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 } }
Para corregir esta advertencia, elimine todas las vinculaciones no deseadas en caso de que la propiedad por defecto no deba ser una lista:
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.