Results 1 to 5 of 5

Thread: No Sort Vertical Header

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question No Sort Vertical Header

    By using QSortFilterProxyModel, then when sorting, the sequence of the vertical header in QTableView also changed. How do I not change order number in the vertical header when column sorted ?



    Sorry, my english is bad

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No Sort Vertical Header

    Reimplement headerData() on the proxy and always return the regular sequence of row numbers.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: No Sort Vertical Header

    OK, I so confused. Can you give me example code ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No Sort Vertical Header

    Qt Code:
    1. QVariant myProxy::headerData(int section, Qt::Orientation orientation, int role) const {
    2. if(orientation!=Qt::Vertical || role!=Qt::DisplayRole)
    3. return QSortFilterProxyModel::headerData(section, orientation, role);
    4. return section;
    5. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following 2 users say thank you to wysota for this useful post:

    ce_nort (30th March 2016), wirasto (1st July 2009)

  6. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Smile Re: No Sort Vertical Header

    That's can start from 0

    So, i chane like this

    Qt Code:
    1. QVariant MyProxy::headerData(int section, Qt::Orientation orientation, int role) const {
    2. if(orientation!=Qt::Vertical || role!=Qt::DisplayRole)
    3. return QSortFilterProxyModel::headerData(section, orientation, role);
    4.  
    5. return section+1;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Thank's for your sample code. Solved now.

Similar Threads

  1. Replies: 3
    Last Post: 20th January 2011, 13:24
  2. Replies: 3
    Last Post: 1st February 2008, 18:18
  3. QTreeView and QDirModel Header Sort Question
    By jimroos in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2007, 08:04
  4. Showing Icon in vertical header of a table
    By vishal.chauhan in forum Qt Programming
    Replies: 7
    Last Post: 15th January 2007, 10:44
  5. Items in QListView should sort on Header Click
    By vinnu in forum Qt Programming
    Replies: 14
    Last Post: 10th November 2006, 12:49

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.