Results 1 to 3 of 3

Thread: Disable sorting for a column on QTableView

  1. #1
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Disable sorting for a column on QTableView

    I am using QTableView with a QSortFilterProxyModel(). By default, all columns on QTableView is sortable by clicking individual column header. But for my application, I do not want the users to sort the rows by column 0. Or put it this way, no sorting when the header of column 0 is clicked. Is there any way to do this?

    Thanks a lot,
    PX

  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: Disable sorting for a column on QTableView

    Subclass the proxy model and reimplement sort() so that there is no sorting for the column you want.
    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. The following user says thank you to wysota for this useful post:

    chapu (29th March 2012)

  4. #3
    Join Date
    Apr 2010
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Disable sorting for a column on QTableView

    Thanks a lot. It works very well.

Similar Threads

  1. Replies: 1
    Last Post: 15th February 2012, 14:56
  2. How to disable sorting option in QMap
    By baluk in forum Newbie
    Replies: 12
    Last Post: 1st October 2010, 10:10
  3. Sorting column in QTreeWidget
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 14th November 2007, 18:35
  4. How can I disable the QListView Sorting?
    By darpan in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2006, 10:36
  5. Column Sorting
    By sumsin in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 07:48

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.