[Qt-interest] Poor performance of "setBackground()" API in QTableWidgetItem class in Qt 4.5.1

Sean Harmer sean.harmer at maps-technology.com
Thu Jun 11 09:19:17 CEST 2009


Hi,

On Thursday 11 Jun 2009 04:26:25 Mark Pereira wrote:
> Hi,
>
> I have been using Qt 4.3.3 for a while and have recently moved to
> Qt4.5.1. I have noticed that the performance of the "setBackground()"
> API of QTableWidgetItem class has slowed down dramatically.
>
> I have attached a sample piece of code which can be used to reproduce
> this problem. In Qt 4.3.3. it takes around 407msec to complete setting
> the background, while in Qt 4.5.1 it takes 68,567msec for the same task.
> I ran this test on a Intel Core Duo PC (1.8 GHz) with 2 GB RAM.
>
> Any suggestions as to how to improve this performance.
Why not set the background colour of the whole widget just once rather than 
setting the background colour of each of many items?

Two simple ways to do this:

(i) Set the Base color in the widgets pallet and then setAutoFillBackgrround( 
true ).

or 

(ii) Use a simple style sheet:

QTableWidget {
background-color: yellow;
}

Cheers,

Sean




More information about the Qt-interest-old mailing list