Results 1 to 2 of 2

Thread: Reset QTableWidget sorting order

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2017
    Posts
    11
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Reset QTableWidget sorting order

    I am currently working with QTableWidget and I have enabled the column sorting order for the user. I need to be able to switch this sorting order off again. Most other UI appraches allow you to click cycle trough sorting options, descending/ascending/resetOrder. Is this feature available?

    I also tried resetting the order with an additional context menu, but I could only find reset options for qTableView, not qTableWidget:
    http://stackoverflow.com/questions/1...ortfilterproxy

    Is there anything that I am missing here?

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

    Default Re: Reset QTableWidget sorting order

    There is no direct API or trivial way to restore the original order with QTableWidget as you don't have access to it's model. There is a simple ways for QTableView because you can change the model.

    A not so straight forward approach would be to some how record and store the un-sorted order of items, and restore it back manually programming it. It may involve re-creation of QTableWidgetItems, it depends on your data model and items.
    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.

Similar Threads

  1. Replies: 3
    Last Post: 11th August 2015, 00:26
  2. QTableWidget sorting
    By migel in forum Newbie
    Replies: 1
    Last Post: 6th June 2011, 00:08
  3. Sorting a series of QLists into the same order
    By mobucl in forum Qt Programming
    Replies: 8
    Last Post: 25th February 2011, 18:15
  4. QTableWidget and sorting like int
    By TomASS in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 15:54
  5. Sorting a qtablewidget......
    By reshma in forum Qt Programming
    Replies: 8
    Last Post: 23rd March 2009, 15:34

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
  •  
Qt is a trademark of The Qt Company.