Results 1 to 4 of 4

Thread: Using QSortFilterProxyModel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Using QSortFilterProxyModel

    Quote Originally Posted by Jennie Bystrom View Post
    I have two table views that should visualize the same data. One is a filtered version of the other so it will not show all columns. I call them collapsedView and expandedView. Both are QTableView.
    You don't need a proxy model to hide columns if that's all difference between them. You can use QTableView::setColumnHidden().

    Qt Code:
    1. QTableView* collapsedView = new QTableView();
    2. QTableView* expandedView = new QTableView();
    3.  
    4. SourceModel* sourceModel = new SourceModel();
    5. FilterModel* filterModel = new FilterModel();
    6. filterModel->setSourceModel(sourceModel);
    7.  
    8. collapsedView->setModel(filterModel);
    9. expandedView->setModel(filterModel);
    10.  
    11. collapsedView->setColumnHidden(2, true); // hide for example second column
    To copy to clipboard, switch view to plain text mode 
    This way sorting should work correctly out of the box in both views.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    Jennie Bystrom (6th December 2007)

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.