[PyQt] qtreeview display speed
Babak Khataee
babakage at gmail.com
Mon Feb 4 18:41:02 GMT 2008
Hi Matt,
Thanks for your response, I'm using Qt 4.2.
cheers
Babak
On 04/02/2008, Matt Newell <newellm at blur.com> wrote:
>
> On Monday 04 February 2008 08:52:44 Baba-k wrote:
> > Hi everyone,
> >
> > I'm relatively new to pyqt and am encountering some problems while
> trying
> > to make a custom tree widget (using the model/view classes) that i was
> > hoping some one here might be able to help me with.
> >
> > Ive made a custom treewidget which is using a custom view and model. The
> > view is a subclass of QTreeView and the model a subclass of
> > QAbstractItemView. The model class takes its data in the form of a
> custom
> > item class. Both the custom model and item classes are very similar to
> the
> > examples in the docs just with some extra functionality where needed.
> The
> > model and view classes are being used in a custom QWidget which is
> inside a
> > QDialog.
> >
> > The tree is designed to show the difference between two hierarchies of
> > data, the size of these hierarchies can vary. Before calling the 'show'
> > method of the QDialog object, the items inside the tree are expanded.
> > The problem I'm having is that when displaying fairly large hierarchies
> > (7000+ rows) it can take onwards of 10mins for the contents of the
> widget
> > to be drawn. If I don't expand the items in the tree before calling
> 'show'
> > the it is pretty much instant. Has anyone experienced anything like this
> > before ??
> >
> > Any ideas or suggestions about this would be very much appreciated :)
> >
> > thanks alot
> > babak
>
> Which version of qt are you using? Each expanded item is (internally)
> stored
> as a qpmi(QPersistentModelIndex). With Qt versions < 4.3.0, creating each
> qpmi is an O(n) operation, where n is the number of existing qpmis. Since
> you are expanding all the items in the view, that results in an O(n^2)
> operation.
>
> With qt >= 4.3.0, qpmi creation is O(log n), since they are stored in a
> sorted
> list, and a binary search is used to find/create the new qpmi. With your
> code, this would result in total complexity of O(n log n), quite an
> improvement.
>
> Matt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080204/b32dce48/attachment.html
More information about the PyQt
mailing list