[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] slowness of QTableWidget sort ?
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2006-08-24 8:19:23
Message-ID: 20060824081923.GB5326 () morpheus ! apaku ! dnsalias ! org
[Download RAW message or body]

On 24.08.06 09:28:34, bastian salmela wrote:
> I have rather big list of things (9000 rows, 7 columns) that I read from file, 
> and add to QTableWidget, and it seems _very_ slow..

Don't use a QTableWidget for this.

> the filling of table takes some (5-10) seconds, and when I click some of the 
> headers to sort it, it takes minutes. so obviously that was not usable. 
> I decided test the loading and sorting in just python lists and list.sort() and 
> guess what, whole process takes 1 or 2 seconds.. 
> I understand 9000 rows is a lot, and as this is a toplist, i dont necessary 
> need that many, so after inital sort I now add to QTableWidget only 500 first 
> on the list, which makes the table usable. clicking the headers for sorting it 
> according to another column, still takes a bit though, and it got me 
> wondering.. 
> so why is QTableWidget so slow?

Because it works on QTableWigdetItem's not just strings or numbers. It
has to sort complex items. Also I'm not sure, but the QTableWidget has
to store all it's items in memory at once which maybe quite a lot with
9000x7.

Use a QTableView together with an apropriate model. You may be able to
just use QStandardItemModel or you can roll your own with
QAbstractTableModel as base. That'll probably speed up things a lot.

Andreas

-- 
You will never know hunger.

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic