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
void InsertRow(int iRow)
{
tableDataWidget->insertRow(iRow);
// Colum 0 -- Row number
tableDataWidget->setItem(iRow,0,TableItem);
// Colum 1 -- Sample Type
aString = Data->GetDataBaseItemLabel(SampleType);
aString += "-";
aString
+= QString::number(SampleType
);
tableDataWidget->setItem(iRow,1,TableItem);
// Colum 2 -- Sample Time
ThisTime.setTime_t(SampleTakenTime);
TableItem
= new QTableWidgetItem(ThisTime.
toString(Qt
::SystemLocaleShortDate) );
// Colum 3 -- Sample Load Time
tableDataWidget->setItem(iRow,2,TableItem);
ThisTime.setTime_t(SampleLoadedTime );
// Colum 4 -- This Time
TableItem
= new QTableWidgetItem(ThisTime.
toString(Qt
::SystemLocaleShortDate) );
tableDataWidget->setItem(iRow,3,TableItem);
}
void InsertRow(int iRow)
{
tableDataWidget->insertRow(iRow);
// Colum 0 -- Row number
TableItem = new QTableWidgetItem(QString::number(iRow) );
tableDataWidget->setItem(iRow,0,TableItem);
// Colum 1 -- Sample Type
aString = Data->GetDataBaseItemLabel(SampleType);
aString += "-";
aString += QString::number(SampleType);
TableItem = new QTableWidgetItem(aString);
tableDataWidget->setItem(iRow,1,TableItem);
// Colum 2 -- Sample Time
ThisTime.setTime_t(SampleTakenTime);
TableItem = new QTableWidgetItem(ThisTime.toString(Qt::SystemLocaleShortDate) );
// Colum 3 -- Sample Load Time
tableDataWidget->setItem(iRow,2,TableItem);
ThisTime.setTime_t(SampleLoadedTime );
// Colum 4 -- This Time
TableItem = new QTableWidgetItem(ThisTime.toString(Qt::SystemLocaleShortDate) );
tableDataWidget->setItem(iRow,3,TableItem);
}
To copy to clipboard, switch view to plain text mode
Bookmarks