PDA

View Full Version : ListView model binding to QAbstractListModel



michalk
14th July 2011, 07:35
I am unable to make my class derived from QAbstractListModel working with qml ListView.

Situation looks like this:

I have created ButtonMenu QML element:


Rectangle {
id: menuRoot
...
property Component model
...

In this element I have another one and in this another one I have ListView element


Rectangle {
id: menu
...
ListView {
id: menuList
...
model: menuRoot.model;
...


Now when I create ButtonMenu element I have something like this:


ButtonMenu {
id: buttonMenu
...
model: menuMainViewArea
...


In C++ I do this:

ctxt->setContextProperty("menuMainViewArea",engine.getMenuMainViewArea());


When I run my program i get following error:
Error: Cannot assign QObject* to QDeclarativeComponent*

I tried to make model in menuRoot an alias to menuList model but when I called model.count when setting size of all rectangles I got model.count undefined.

Does anyone know what can be wrong??

michalk
16th July 2011, 10:21
Discussion and solution to this issue are presented in this post (http://developer.qt.nokia.com/forums/viewthread/7770/)