Results 1 to 4 of 4

Thread: Sorting issue

  1. #1

    Default Sorting issue

    Hi all,

    In my project I have a QTableView which displays the information contained in my data model - 40 rows and 20 columns. That information is updated every 100 miliseconds.


    Everything works fine however the application performance decreases a lot everytime column sorting is activated. I use a QSortFilterProxyModel to perform column sorting.

    i.e:
    If I have 2 windows, each one with an instance of the mentioned tableview, if I sort both tables the UI thread goes from less than 20% to 100% CPU usage ... even if I'm only sorting by the row number, which means, no change in row positions

    Is this a common issue?
    How can I improve the sorting performance?

    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sorting issue

    One option is to sort in the model itself.

    As it "knows" the data, it can more easily decide if order of items change when data changes or which rows move where.

    Cheers,
    _

  3. #3

    Default Re: Sorting issue

    Thanks for the tip. But, shouldn't QSortFilterProxyModel be optimized to sort decimals and text strings?

    By the way, I'm setting setDynamicSortFilter to true.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sorting issue

    A proxy model doesn't have any structural or semantic knowledge about the data to the source model, it can only perform sorting by applying a standard sorting algorithm.

    A model that sorts its on data can use that additional information to avoid applying the sorting agorithm on all data.

    Example: the data has a numerical field and you sort by that.
    Both approaches have to do the same work for the initial sorting.

    Now assume that some function increments all values by the same amount.
    The proxy only knows that values have change, it has to re-sort the entire model.
    The model itself knows that all values are still in the same order, it doesn't have to do anything.

    Cheers,
    _

Similar Threads

  1. QStandardItemModel / QTableView sorting issue
    By AlphaWolfXV in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2010, 05:42
  2. QTableWidget and sorting like int
    By TomASS in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 14:54
  3. Sorting
    By bismitapadhy in forum Qt Programming
    Replies: 26
    Last Post: 30th January 2010, 16:59
  4. Sorting a QStringlist issue
    By George Neil in forum Qt Programming
    Replies: 4
    Last Post: 30th September 2009, 05:23
  5. QFileSystemModel has no sorting
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 28th May 2009, 08:14

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.