[Kde-bindings] Subclassing any data models causes the interface to be slow

Arno Rehn arno at arnorehn.de
Thu Oct 9 12:41:23 UTC 2008


On Thursday 09 October 2008 10:30:58 Chris Burel wrote:
> I was testing out making a subclass of QAbstractItemModel in my
> PerlQt4 implementation, and I noticed that when I hook up something
> like a TreeView to my custom model, the interaction of the interface
> slows down quite noticeably.  So I tried out the
> examples/itemviews/simpletreemodel example in QtRuby (I had to muck
> with it a bit to get it to run...) to find the same issue.  It's
> clearly visible when you toggle between maximized and non-maximized
> states, the repaint takes about half a second to occur.  This
> half-second delay is also apparent when you try to expand any of the
> children in the tree view.  I did some profiling of my perl code and
> found that on a simple action such as the window gaining or losing
> focus, the data method of the data model was called about 400 times,
> and a click causes 1000-2000 calls, so I expect this is the cause of
> things being slow.
Strange, I don't experience any delays, but I have fairly recent hardware.

> Is this a known problem?  My understanding is that to use any
> List/Tree/Table view in Qt4 and display useful data, you have to
> subclass one of the data model classes.  Are there any ideas on how to
> reduce that delay when using a custom data model?
You could special case the data method and try to cache the value on the C++ 
side so you don't always have to call back into perl. To know when the data 
has changed, the user would need to always emit dataChanged() when someone 
calls setData(), though.

-- 
Arno Rehn
arno at arnorehn.de



More information about the Kde-bindings mailing list