Results 1 to 5 of 5

Thread: QTableWidget sorting

  1. #1
    Join Date
    Jul 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTableWidget sorting

    Hi

    I want to have QTableWidget sorted according to polish language. I have the parent window set to polish/Poland but QTableWidget is sorting wrong. What should I set else ?

    thanks
    Ryszard

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget sorting

    what do you mean by
    I have the parent window set to polish/Poland
    How did you do that?
    Show us some code, please.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableWidget sorting

    You may reimplement QTableWidgetItem::operator<() if you want to have custom sorting.
    J-P Nurmi

  4. #4
    Join Date
    Jul 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget sorting

    I can see that in properties table of window in Designer. locale: language:Polish, country:Poland.
    I thik this is default setting in my system.
    But I also tried add
    setLocale(QLocale(QLocale::Polish,QLocale::Poland) );
    into constructor of my window. Without effect.

  5. #5
    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: QTableWidget sorting

    Do what J-P suggested. You are observing the effect because the sorting is based not on the widget that displays the content, but on QString that is kept in the model that the widget uses and QStrings are compared according to C locale. You need to compare using QLocale to have the proper order.

Similar Threads

  1. QTableWidget sorting with hidden rows
    By alex140773 in forum Qt Programming
    Replies: 0
    Last Post: 8th July 2008, 12:35
  2. QTableWidget Sorting Widgets!
    By VireX in forum Qt Programming
    Replies: 4
    Last Post: 14th April 2007, 01:08
  3. Sorting elements in QTableWidget
    By Elmo23x in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2007, 08:35
  4. QTableWidget Sorting
    By mclark in forum Newbie
    Replies: 4
    Last Post: 29th September 2006, 22:34
  5. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 21:05

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.