Results 1 to 3 of 3

Thread: disable sorting on a QTableWidget

  1. #1
    Join Date
    May 2017
    Posts
    6
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Question disable sorting on a QTableWidget

    Hi everyone,
    I wanted to know if there is an issue to diasble sorting on a QTableWidget, i recieve frames, process them and then put the information in a QTableWidget just like this :
    sort.png
    if someone click on a column to sort it, it becomes like this :
    sort2.png


    so i want to disable sorting to avoid issues like the second image.
    thank's !

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: disable sorting on a QTableWidget

    Quote Originally Posted by Qt Documentation
    Note that if sorting is enabled (see sortingEnabled) and column is the current sort column, the row will be moved to the sorted position determined by item.
    If you want to set several items of a particular row (say, by calling setItem() in a loop), you may want to turn off sorting before doing so, and turn it back on afterwards; this will allow you to use the same row argument for all items in the same row (i.e. setItem() will not move the row).
    Turn off the sorting when inserting items, then enable it back.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    oazive (4th May 2017)

  4. #3
    Join Date
    May 2017
    Posts
    6
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: disable sorting on a QTableWidget

    It worked fine.
    Thank you !!

Similar Threads

  1. Replies: 3
    Last Post: 11th August 2015, 00:26
  2. Disable sorting for a column on QTableView
    By chapu in forum Qt Programming
    Replies: 2
    Last Post: 29th March 2012, 19:38
  3. QTableWidget sorting
    By migel in forum Newbie
    Replies: 1
    Last Post: 6th June 2011, 00:08
  4. How to disable sorting option in QMap
    By baluk in forum Newbie
    Replies: 12
    Last Post: 1st October 2010, 11:10
  5. How can I disable the QListView Sorting?
    By darpan in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2006, 11:36

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.