Hi Matt, <br><br>Thanks for your response, I'm using Qt 4.2.<br><br>cheers<br> Babak<br><br><div><span class="gmail_quote">On 04/02/2008, <b class="gmail_sendername">Matt Newell</b> <<a href="mailto:newellm@blur.com">newellm@blur.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Monday 04 February 2008 08:52:44 Baba-k wrote:<br>> Hi everyone,<br>><br>> I'm relatively new to pyqt and am encountering some problems while trying<br>> to make a custom tree widget (using the model/view classes) that i was<br>
> hoping some one here might be able to help me with.<br>><br>> Ive made a custom treewidget which is using a custom view and model. The<br>> view is a subclass of QTreeView and the model a subclass of<br>> QAbstractItemView. The model class takes its data in the form of a custom<br>
> item class. Both the custom model and item classes are very similar to the<br>> examples in the docs just with some extra functionality where needed. The<br>> model and view classes are being used in a custom QWidget which is inside a<br>
> QDialog.<br>><br>> The tree is designed to show the difference between two hierarchies of<br>> data, the size of these hierarchies can vary. Before calling the 'show'<br>> method of the QDialog object, the items inside the tree are expanded.<br>
> The problem I'm having is that when displaying fairly large hierarchies<br>> (7000+ rows) it can take onwards of 10mins for the contents of the widget<br>> to be drawn. If I don't expand the items in the tree before calling 'show'<br>
> the it is pretty much instant. Has anyone experienced anything like this<br>> before ??<br>><br>> Any ideas or suggestions about this would be very much appreciated :)<br>><br>> thanks alot<br>> babak<br>
<br>Which version of qt are you using? Each expanded item is (internally) stored<br>as a qpmi(QPersistentModelIndex). With Qt versions < 4.3.0, creating each<br>qpmi is an O(n) operation, where n is the number of existing qpmis. Since<br>
you are expanding all the items in the view, that results in an O(n^2)<br>operation.<br><br>With qt >= 4.3.0, qpmi creation is O(log n), since they are stored in a sorted<br>list, and a binary search is used to find/create the new qpmi. With your<br>
code, this would result in total complexity of O(n log n), quite an<br>improvement.<br><br>Matt<br></blockquote></div><br>