Results 1 to 2 of 2

Thread: QSqlTableModel and QTableView and sorting

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Location
    Groningen Netherlands
    Posts
    182
    Thanks
    16
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSqlTableModel and QTableView and sorting

    Hello,

    I have setSortingEnabled (true) for this table so that when I click on a column header, the table gets sorted to that column. Very nice.

    But in combination with setFilter() the sorting order is not always the same. The order of records is different if a filter is applied.

    There are columns with the same value, and in a normal sql case you would then use an 'order by' with 2 arguments, 'order by thisfirst, thatsecond' which would get around such problems. I suspect this is the reason why the order differs when I set a filter.

    Trying to illustrate:

    Name Type Age (sorted on column Age)
    a 1 1
    b 1 1
    c 2 1

    setFilter(type = 1)

    b 1 1
    a 1 1

    Should be a first, then b.

    Hope I am being a bit clear. Thanks.
    Last edited by JeanC; 4th April 2008 at 18:27.

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.