Results 1 to 4 of 4

Thread: Table Sorting

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Table Sorting

    I have a QTable in Qt 3.3.7 and have it working so I can sort the columns. The one problem is some of my columns contain numerical values and the QTable only sorts by strings. So if I have the numbers 1-30 in a row in my table and I sort that row from lowest to highest, 10-19 is lower than 2 and anything else because "1" comes before "2" in a string. So how do I need to go about doing this? Is there a nice convenience in Qt 3 that I am just not seeing? Thanks for your help!

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Table Sorting


  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Table Sorting

    I have looked at the example but I don't know how this helps me. I am storing data into a QTable and I don't have the ability to overwrite a compare function like the QListViewItem has. I am storing QVariant data into the QTable. I feel like I need a QTable over a QListView because I need to be able to hide and show rows and do not see how to do this with a QListView. Or is there an easy way to show/hide rows (not columns) inside a QListView? Does anybody else have any other ideas?
    Last edited by ToddAtWSU; 29th January 2007 at 22:23.

  4. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Table Sorting

    I have read in many places where it says to modify QTableItem::key( ) for sorting purposes but how do I set it up so I can return an integer for 3 columns in my table and a QString for the other 4 columns in my table? I don't see how it can have 2 different return types and how it will know which column calls it so it will know which return type to return. Thanks!

Similar Threads

  1. QAbstractTableModel row hiding and sorting
    By Rayven in forum Qt Programming
    Replies: 2
    Last Post: 23rd August 2006, 03:39
  2. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 23:12
  3. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 14:50
  4. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 19:06
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 12:03

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.