[Interest] Using QQmlListProperty and QAbstractListModel

BOUCARD Olivier boucard_olivier at yahoo.fr
Fri Apr 6 13:44:06 CEST 2012


Hi all,

I'm trying to use QQmlListProperty with Qt5.
I''ve followed the QtDeclarative Extending Chapter 5 tutorial, with PieChart and PieSlice, which works.
I want to fill a custom model from QML with specific items. Maybe there is another way but I didn't found it.

 
I have a class MyModelItem which extends QObject with some properties.
I have a class MyModel which extends QAbstractListModel with a QQmlListProperty<MyModelItem> property with the proper callbacks.

When I try to fill my model from QML with something like this:

MyModel {
items: [
MyModelItem {
name: "item 1"

},
MyModelItem {
name: "item 2" 
}
]

}

I have the following error: "Cannot assign multiple values to a singular property".

What am I doing wrong?

Thank you.

Olivier.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120406/8beead9e/attachment.html>


More information about the Interest mailing list