[Qt-interest] Slow? painting of rows in QTableWidget

Sandro Frenzel Sandro.Frenzel at gmx.de
Wed Mar 25 22:33:51 CET 2009


-------- Original-Nachricht --------
> Datum: Wed, 25 Mar 2009 20:42:26 +0100
> Von: Andreas Pakulat <apaku at gmx.de>
> An: qt-interest at trolltech.com
> Betreff: Re: [Qt-interest] Slow? painting of rows in QTableWidget

> On 25.03.09 18:29:36, Sandro Frenzel wrote:
> > Hello,
> > 
> > I experiment with tables in QT4. I create a QTableWidget and insert
> > 600
> > new rows. It takes 5 seconds on a 2,5 GHZ Intel Core2Duo to paint all > > rows.
> > 
> > My question: Is that normal? Can I accelerate this operation?
> 
> Did you profile your app to see where the time is spent? If you add all
> items in a short loop that should be relatively fast as there's no
> gui-updates in between. However the tablewidget class might do layout
> recalculations on each new row, you can help with that by specifying 
> that
> your items all have the same height and/or width (there's a setter for
> that
> in the QTableView base class).
> 

Hm, I have implemented following simple loop:
 
void MainWindow::on_pushButton_clicked() {   

int i = 0;
while(i<650) {
   ui->tableWidget->insertRow(i);
   i++;
}

}

The rows are shown at once, when the loop ist completed (5 seconds). Height and width are set in the designer.  


> Another downside of qtablewidget is that you can't easily add n rows at
> once, with only one relayouting being done. For that you'd have to use
> QTableView+Model (not sure wether QStandardItemModel would be of use for
> that).
> 

Can you give me a little example? I found nothing about it. I can set the 650 rows in the table-model and show it without waiting?

> If that doesn't help you really need to profile your application.
> 
> Andreas
>  

Bye,
Sandro


-- 
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a



More information about the Qt-interest-old mailing list