Results 1 to 2 of 2

Thread: Tree model - Proxy model that wrapped original model under a single parent node

  1. #1
    Join Date
    Jul 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Tree model - Proxy model that wrapped original model under a single parent node

    i am trying to create a proxy model using a read-only model that will have all the item in the R/O model under a single tree parent node. What function do I need to overwrite to make this happened? Do I derived from QAbstractItemModel or QAbstractProxyModel?

    Example:
    Original model
    * A
    ** x y
    * B
    * C
    ** x y

    Proxy Model (what I want)
    * Name-String
    ** A
    *** x y
    ** B
    ** C
    *** x y

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Tree model - Proxy model that wrapped original model under a single parent node

    i am trying to create a proxy model using a read-only model that will have all the item in the R/O model under a single tree parent node......Do I derived from QAbstractItemModel or QAbstractProxyModel?
    As you want to implement proxy model you should derive from QAbstractProxyModel

    What function do I need to overwrite to make this happened?
    Implement mapFromSource(), mapToSource(), columnCount(), rowCount(), index(), parent(), and data()
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Accessing parent IndexModel in a tree Model
    By Guett_31 in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2013, 08:31
  2. Custom Model and Proxy Model
    By frank100 in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2010, 15:30
  3. Making a tree proxy model with multiple sources
    By Mookie in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2010, 04:28
  4. Insert parent item in proxy model
    By geflei in forum Newbie
    Replies: 0
    Last Post: 9th May 2010, 17:15
  5. disable a parent and children in a tree model
    By qt_gotcha in forum Newbie
    Replies: 4
    Last Post: 9th July 2009, 07:49

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.