Results 1 to 4 of 4

Thread: Setting/getting sortcolumn/sortorder

  1. #1
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Setting/getting sortcolumn/sortorder

    I want to save the sortcolumn and sortorder of a QTableModel->QSortFilterProxyModel->QTreeView with QSettings.

    I'm finding it a challenge to set and/or get these two settings from my little setup. I would expect to find a function specifically meant to get and restore these settings, like there is one to get and restore the toolbar-positions.

    The actual sorting happens in the QSortFilterProxyModel, doesn't it? But I can't find the functions I need in there.

    Any help?

    Thanks in advance!
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Setting/getting sortcolumn/sortorder

    I don't believe you can.
    You should store somewhere ( in the model, the view, or wherever is accessible ), the sort order and sort column. In the model would be best to store it.

    When you load it again, just pass the sort column and sort order as you would normally do.

    Regards

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

    Default Re: Setting/getting sortcolumn/sortorder

    You can use QHeaderView::sortIndicatorSection() and QHeaderView::sortIndicatorOrder() to save and QTreeView::sortByColumn() to restore. The header is accessible via QTreeView::header().
    J-P Nurmi

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

    Michiel (27th May 2007)

  5. #4
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Setting/getting sortcolumn/sortorder

    Quote Originally Posted by jpn View Post
    Works for me. Thanks!

    I think they should put those get-functions in the QTreeView. But that's just me.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

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.