Results 1 to 2 of 2

Thread: ListView model binding to QAbstractListModel

  1. #1
    Join Date
    Feb 2011
    Location
    Poland
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default ListView model binding to QAbstractListModel

    I am unable to make my class derived from QAbstractListModel working with qml ListView.

    Situation looks like this:

    I have created ButtonMenu QML element:
    Qt Code:
    1. Rectangle {
    2. id: menuRoot
    3. ...
    4. property Component model
    5. ...
    To copy to clipboard, switch view to plain text mode 
    In this element I have another one and in this another one I have ListView element
    Qt Code:
    1. Rectangle {
    2. id: menu
    3. ...
    4. ListView {
    5. id: menuList
    6. ...
    7. model: menuRoot.model;
    8. ...
    To copy to clipboard, switch view to plain text mode 

    Now when I create ButtonMenu element I have something like this:
    Qt Code:
    1. ButtonMenu {
    2. id: buttonMenu
    3. ...
    4. model: menuMainViewArea
    5. ...
    To copy to clipboard, switch view to plain text mode 

    In C++ I do this:
    Qt Code:
    1. ctxt->setContextProperty("menuMainViewArea",engine.getMenuMainViewArea());
    To copy to clipboard, switch view to plain text mode 

    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??

  2. #2
    Join Date
    Feb 2011
    Location
    Poland
    Posts
    12
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: ListView model binding to QAbstractListModel

    Discussion and solution to this issue are presented in this post

Similar Threads

  1. QAbstractListModel
    By Archa4 in forum Newbie
    Replies: 9
    Last Post: 9th February 2011, 15:43
  2. Problem with QAbstractListModel
    By chandan in forum Newbie
    Replies: 0
    Last Post: 12th April 2010, 01:24
  3. QAbstractListModel problem
    By UltimatePace in forum Qt Programming
    Replies: 5
    Last Post: 27th September 2009, 11:51
  4. Problem with QAbstractListModel
    By eekhoorn12 in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2009, 15:26
  5. QAbstractListModel searching.
    By ComaWhite in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2009, 19:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.