Propriété non listée
Cette catégorie d'avertissement est orthographiée « [non-list-property] » par qmllint.
Impossible d'attribuer plusieurs objets à une propriété par défaut non de type liste
Que s'est-il passé ?
Une propriété par défaut possède plusieurs liaisons, mais son type n'est pas un type de liste et n'accepte qu'une seule liaison.
Pourquoi est-ce un problème ?
Toutes les liaisons vers la propriété par défaut, à l'exception de la dernière, seront ignorées. Cela indique très probablement que la propriété par défaut devrait plutôt être une liste, ou qu'il y a trop de liaisons vers la même propriété.
Exemple
Déclarons un composant MyComponent qui possède une propriété par défaut n'étant pas de type liste, puis lions trois éléments à cette propriété par défaut :
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"
}
}Pour corriger cet avertissement, remplacez la propriété par défaut par une liste :
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
}
}Pour corriger cet avertissement, supprimez toutes les liaisons indésirables si la propriété par défaut n’est pas censée être une liste :
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.