Results 1 to 5 of 5

Thread: Row index change when using QSortFilterProxyModel after sorting in QT4

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Row index change when using QSortFilterProxyModel after sorting in QT4

    Ok, then I had get you wrong. Sorry.

    The Solution for your problem is pretty simple:
    Qt Code:
    1. QVariant MySortFilterProxyModel::headerData(int section, Qt::Orientation orientation, int role) const
    2. {
    3. if (role != Qt::DisplayRole)
    4. return QVariant();
    5. if (orientation == Qt::Horizontal)
    6. return QSortFilterProxyModel::headerData(section, orientation, role);
    7. return section + 1;
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 1st March 2011 at 07:45.

  2. #2
    Join Date
    Feb 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Row index change when using QSortFilterProxyModel after sorting in QT4

    Your solution just solves my problem. Thank you very much!

    I wonder how operations perform when there's a proxy model attached to a source model. It seems that a method (virtual method declared in their parent) is first invoked in the proxy model. If we override the method and did not invoke its parent's one, corresponding method will not be invoked. Actually, it's the QSortFilterProxyModel::method() invokes the corresponding method in source model. Is it right?

Similar Threads

  1. DockWidgetArea change and layout direction change
    By mstegehu in forum Qt Programming
    Replies: 1
    Last Post: 21st February 2012, 21:24
  2. Replies: 0
    Last Post: 7th October 2010, 19:38
  3. Readline from a particular index
    By giusepped in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2010, 20:58
  4. Get Row Index
    By wirasto in forum Qt Programming
    Replies: 4
    Last Post: 13th September 2009, 13:57
  5. Get index of QValueListIterator
    By zlatko in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2006, 10:27

Tags for this Thread

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.