[Interest] QTableWidget performance

Paul England pengland at cmt-asia.com
Wed Mar 14 23:54:22 CET 2012


Hi

I've got an old legacy application that I started in Qt3 and have since 
ported to Qt4.  It uses a subclassed QTableWidget.  I'm using about 8 
columns. Data is added at various rates, but I would say by the end of 
the day, it could have several thousand rows.   To boot, I'm actually 
kicking off multiple copies of this class within one process now.    As 
such, I'm starting to see poor performance as the day gets later.   If I 
tail the log, the log tells me it's gotten the data and updated it, but 
the screen doesn't paint the new items until later.

Generally two things happen after getting a new message
1: Look through the last 200 - 300 records -- if it's an update, update 
that cell.
1B: The caveat here is there maybe something that should be updated, but 
I'm assuming it's old at that point and don't care if it's repainted.
2: If it's new, insertRow( 0 ) and fill this row w/ the data.

Each time I insert a row, I store the identifier w/ it's "index" in a 
deque.  The deque generally only holds 200-300 records, so the look up 
is quite fast.  I am assuming that searching through 
std::deque<my_map_t> (where my_map_t has a QString and int member only) 
is faster than going through each row and examining the QTableWidgetItem 
of a specific cell.

My main question is, insertRow() in a QTableWidget with 10 rows, as fast 
as insertRow on a QTableWidget with 10,000 rows?   I've done quite a bit 
of housecleaning to make it quicker, and I've seen good results, but not 
quite there yet, as I can visually see.  I have loaded up a table in a 
test mode, with some 20,000 rows of data, and can simulate adding a 
couple of rows a time.  I do not see the delay, so my guess is that 
insertRow() is not that big of a deal.  The problem is that means I have 
no clue where the performance issue is. :(

The obvious questions is of course, should I use a QTableView instead?  
My main resistance to this is  that while the data is somewhat simple, I 
already have a pretty complex system to filter what should be displayed 
and what shouldn't, what colors should be displayed for visible items, 
what font to use, and whether a sound should be played or not.  This is 
all configured by the user in the GUI.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120315/9fcef3e2/attachment.html>


More information about the Interest mailing list