Results 1 to 9 of 9

Thread: Which Common Model can be used for Tree View Display and List View Display ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    151
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6
    Thanked 13 Times in 11 Posts

    Default Re: Which Common Model can be used for Tree View Display and List View Display ?

    Your treemodel will index every element added to the tree.

    For any given item in the tree you can get the other elements at the same level using the sibling function.

    For more info take a look at the documentation for QModelIndex.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Which Common Model can be used for Tree View Display and List View Display ?

    Store your data in a basic table model with a the hierarchy you want for your tree view. If the children you want to show in your list view are all of the same parent then you might consider using a single-columned tree view and QTreeView::setRootIndex(). If not, as would seem to be the case in your example, write a QAbstractItemProxyModel derivative to filter the underlying table to produce a single-columned list for your list view.

    I think the browser example in the Qt distribution/demos contains an implmentation described here http://labs.trolltech.com/blogs/2008...-of-modelview/

  3. #3
    Join Date
    Mar 2010
    Posts
    22
    Qt products
    Qt4
    Platforms
    Symbian S60
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Which Common Model can be used for Tree View Display and List View Display ?

    Thanks a lot guys.... Tried a bit but the solution seems to be somewhat complex ..Going with a Two Model Strategy right now and will try on the suggestion again
    sometime later .

Similar Threads

  1. Replies: 33
    Last Post: 7th December 2009, 10:11
  2. How to map tree model data to list view
    By msopanen in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2009, 19:56
  3. Problems to display a QFont in a View/Model correctly
    By NoRulez in forum Qt Programming
    Replies: 0
    Last Post: 8th July 2009, 12:26
  4. Replies: 1
    Last Post: 16th January 2008, 11:48
  5. Model-view: Display items in different ways
    By taboom in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2007, 19:05

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
  •  
Qt is a trademark of The Qt Company.