<div>I sent and email with maybe a related issue a few weeks back. This email does not seem to have reached the mailing list, so here it is again. I have an issue with the sort() method that seems to be called too often. I know there have been some issues previously, and that Mark recommended in his book to turn off the setSortingEnabled() before populating a QTableWidget(). This issue is supposed to have been solved, but maybe not?</div>
<div> </div>
<div>I am looking at a model with up to 1 million rows (as a benchmark and future reference) so I would really like to know about potential problems.</div>
<div> </div>
<div>Regards,</div>
<div>Bjorn</div>
<div> </div>
<div>Hi,<br> <br>I have a QAbstractTableModel with a reimplemented sort() method. The model is set with a QTableView with horizontal headers. The sort() method is supposed to be called only when I click on a header section, which it successfully does, and everything is working fine in that sense. However, the sort() method is called 2 times when the application starts up when the setSortingEnabled(True) is set (if setSortingEnabled(False), then sort is not called).<br>
<br>Why is the sort method called 2 times without me clicking anywhere nor calling the method explicitly? I have been looking into the order of things when starting up the application, but cannot see any difference in whatever I try. This is a problem for large data sets. The model.sort() method is given below with the output.<br>
<br>Regards,<br>Bjorn<br><br></div>
<div class="gmail_quote">On Wed, May 12, 2010 at 1:04 AM, Mark Summerfield <span dir="ltr"><<a href="mailto:list@qtrac.plus.com">list@qtrac.plus.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="im">On 2010-05-12, Steve Borho wrote:<br>> Hello,<br>><br>> The TortoiseHg project is currently porting all of our PyGTK apps to<br>> PyQt, This has been going pretty well so far, but I've hit a snag with<br>
> our file status browser.<br>><br>> I have a simple QAbstractTableModel (4 columns) being displayed in a<br>> QTreeView. After connecting a QSortFilterProxyModel between the tree<br>> view and the data model, reloading the model became very expensive for<br>
> moderately sized data sets. After calling setSourceModel() with a<br>> model of 555 rows, I counted over 3 million calls to the model data()<br>> method, which takes about 15 seconds.<br><br></div>Have you tried switching off sorting just before resetting the model and<br>
then switching it back on afterwards?<br><br>[snip]<br><font color="#888888"><br><br>--<br>Mark Summerfield, Qtrac Ltd, <a href="http://www.qtrac.eu/" target="_blank">www.qtrac.eu</a><br> C++, Python, Qt, PyQt - training and consultancy<br>
"Programming in Python 3 (Second Edition)" - ISBN 0321680561<br></font>
<div>
<div></div>
<div class="h5">_______________________________________________<br>PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</div></div></blockquote></div><br>