Results 1 to 3 of 3

Thread: QTreeView + QSortFilterProxyModel + Subclassed QAbstractItemModel : Performance issue

  1. #1
    Join Date
    Sep 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeView + QSortFilterProxyModel + Subclassed QAbstractItemModel : Performance issue

    Hi,

    I have a QTreeView that displays realtime information for about 400 items. At a time, only about 10 rows are visible in the treeview. The CPU utilization is very very high (and performance is very bad).
    Currently, in my model, any time one of the item's data is changed in the underlying datastore, I emit a dataChanged signal.
    To optimise this a bit, I maintained a integer topmostItem and integer bottommostItem, and in a 20 msec window, all the changes in the datastore are aggregated and I emit a dataChanged(createIndex(...topmostRow), ...bottommostRow). Even this has very bad performance.

    What must I do to improve performance?

    Thanks in advance.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView + QSortFilterProxyModel + Subclassed QAbstractItemModel : Performance i

    Did you try taking out the proxy model? It is reportedly slow. If that doesn't do it, you probably need a slightly different approach. I'm not sure how fast your data comes in, but if you gather data in a 20 ms window (50Hz) you are probably displaying data faster than you can read in the first place. Is the high update rate required in your case?
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Sep 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeView + QSortFilterProxyModel + Subclassed QAbstractItemModel : Performance i

    Hi,

    I did remove the proxy model to see if CPU utilization goes down : it doesnt.

    The data comes in very fast (once every couple of milliseconds, say), and I figured, I need not emit a dataChanged everytime a new data event happens. I also figured 50Hz was a reasonable refresh rate (if I concentrate on only one item, I should be able to see it change in pseudo-real-time).

    I also ran gprof to see where Qt spends the most time,

    Flat profile:

    Each sample counts as 0.01 seconds.
    % cumulative self self total
    time seconds seconds calls ms/call ms/call name
    21.14 0.74 0.74 92921396 0.00 0.00 QBasicAtomicInt::ref()
    20.57 1.46 0.72 95210967 0.00 0.00 QBasicAtomicInt::deref()
    5.71 1.66 0.20 79832888 0.00 0.00 QString::~QString()
    5.14 1.84 0.18 77860385 0.00 0.00 QString::QString(QString const&)
    3.86 1.98 0.14 49350258 0.00 0.00 QList<QString>::detach()
    2.43 2.06 0.09 56066724 0.00 0.00 QBasicAtomicInt:perator!=(int) const
    Not quite helpful. I commented out the emitting of dataChanged, and the CPU utilization drops to near-0 ... which makes me wonder if somehow I can figure out if the item whose data is being changed is visible in the view's viewport (the majority of the items are hidden ... and furthermore, if item A is at the top and item B at the bottom, and these 2 get updated in a 20 ms window, I am currently emitting dataChanged for the entire rectangle defined by these two end-points ... )

    Is there any way to improve performance? (Sorting is very desirable in the app ... not necessarily real-time sorting, but sorting on the non-realtime columns).

Similar Threads

  1. Replies: 3
    Last Post: 24th February 2011, 15:46
  2. Subclasing QAbstractItemModel Issue
    By wolfi3b in forum Qt Programming
    Replies: 12
    Last Post: 25th September 2010, 10:23
  3. connecting issue with QAbstractItemModel
    By dave_mm0 in forum Qt Programming
    Replies: 3
    Last Post: 29th July 2009, 15:01
  4. QSortFilterProxyModel and QTreeView
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 17th April 2009, 11:50
  5. QSortFilterProxyModel & QTreeView
    By Bear in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 16:04

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.