I am running into a performance issue loading data into a QTableWidget when only loading 100-300 rows. It can take 10-20 seconds to load this data so I have to be doing someing wrong. Below is a snipet of code that is called for every row. I normally load 8 -9 columns but only the first 5 columns are shown below. All data is text based. No graphics or anything else. This is new Tablewidget which has no data in it at the beginning and I am just loading the table with data. Any suggestions on what my problem is?

Ken



Qt Code:
  1. void InsertRow(int iRow)
  2. {
  3.  
  4. tableDataWidget->insertRow(iRow);
  5.  
  6. // Colum 0 -- Row number
  7. TableItem = new QTableWidgetItem(QString::number(iRow) );
  8. tableDataWidget->setItem(iRow,0,TableItem);
  9.  
  10. // Colum 1 -- Sample Type
  11. aString = Data->GetDataBaseItemLabel(SampleType);
  12. aString += "-";
  13. aString += QString::number(SampleType);
  14. TableItem = new QTableWidgetItem(aString);
  15. tableDataWidget->setItem(iRow,1,TableItem);
  16.  
  17. // Colum 2 -- Sample Time
  18. ThisTime.setTime_t(SampleTakenTime);
  19. TableItem = new QTableWidgetItem(ThisTime.toString(Qt::SystemLocaleShortDate) );
  20.  
  21. // Colum 3 -- Sample Load Time
  22. tableDataWidget->setItem(iRow,2,TableItem);
  23. ThisTime.setTime_t(SampleLoadedTime );
  24.  
  25. // Colum 4 -- This Time
  26. TableItem = new QTableWidgetItem(ThisTime.toString(Qt::SystemLocaleShortDate) );
  27. tableDataWidget->setItem(iRow,3,TableItem);
  28.  
  29. }
To copy to clipboard, switch view to plain text mode