Results 1 to 2 of 2

Thread: Using a single model for views that show different column data

  1. #1
    Join Date
    Apr 2008
    Posts
    73
    Thanks
    11
    Thanked 7 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Arrow Using a single model for views that show different column data

    Hi,
    here's what I want to do. I have a model which is used in a tree view, but what I want to do is to have different tree views that show different columns.

    For example, the model contains all the data that I want (e.g. Name, Address, Type, Temperature, Light), and I want the first view to only show Name, Address and Type. Then I want the second view to show Name, Temperature and Light. (Almost poetic!)

    I thought of passing a "View Type" parameter to the models constructor so that it only generates columns appropriate to that view but I'm sure there is a more elegent way to do it. Any idea's how?
    Best Regards,
    Phil Winder
    www.philwinder.com

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using a single model for views that show different column data

    You can use QSortFilterProxyModel: create one proxy for each treeview and filter out unwanted columns.

    Or you can operate on the view level: QTreeView::hideColumn()
    HTH

  3. The following user says thank you to caduel for this useful post:

    philwinder (23rd November 2008)

Similar Threads

  1. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 16:26
  2. Something fishy about Model, data doesn't show up!
    By zlosynus in forum Qt Programming
    Replies: 4
    Last Post: 4th August 2008, 15:07
  3. Data model
    By steg90 in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2007, 12:14
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Model, view, resize to show all data
    By jcr in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2006, 20:59

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.