Results 1 to 20 of 21

Thread: QTableWidget case sensitive sort

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2008
    Posts
    60
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget case sensitive sort

    Dear wysota,

    Thanks you sooo... much.

    tableWidget ()->horizontalHeader () ->sortIndicatorOrder ()
    - this helps me a lot to do proper sorting.

    Thank you.

  2. #2
    Join Date
    Jul 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: QTableWidget case sensitive sort

    this topic really help me,
    I think post the modified code may help more.
    Qt Code:
    1. //.h file
    2. class CTableWidgetItem: public QTableWidgetItem
    3. {
    4. public:
    5. CTableWidgetItem();
    6. CTableWidgetItem(const QString &text,int type= Type):QTableWidgetItem( text,type){};
    7. virtual bool operator<(const QTableWidgetItem &item) const;
    8. };
    9. //.cpp file
    10. CTableWidgetItem::CTableWidgetItem()
    11. {
    12. }
    13.  
    14. bool CTableWidgetItem::operator<(const QTableWidgetItem &item) const
    15. {
    16. if(text().toUpper()<item.text().toUpper())
    17. return true;
    18. else
    19. return false;
    20. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget case sensitive sort

    If we are using proxy model, the simple one can be sortCaseSensitivity : http://doc.qt.io/qt-4.8/qsortfilterp...nsitivity-prop
    Thanks :-)

Similar Threads

  1. Custom sort with QTableWidget
    By nicolas44 in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 00:47
  2. QTableWidget won't sort cellwidgets!!!
    By Arsenic in forum Qt Programming
    Replies: 7
    Last Post: 21st July 2007, 10:41

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.