wshn13
2nd May 2013, 04:16
Hi ,all:
I am working on a small program .This program is to show info on a QTableWidget , it may have thousand rows , but the main time waste section is a loop , code like below :
int i=0;
vector<Case>::iterator it = tmp.begin();
for(;it!=tmp.end();it++, i++)
{
table->insertRow(i);
table->setCellWidget( i, 0, new QCheckBox(QString("Y/N")));
table->setItem(i, 1, new QTableWidgetItem(((*it).type)));
table->setItem(i, 2, new QTableWidgetItem(QString((*it).name.c_str())));
table->setItem(i, 3, new QTableWidgetItem(QString((*it).note.c_str())));
}
If I delete the line "table->setCellWidget( i, 0, new QCheckBox(QString("Y/N")));" ,the program will go much more faster ,so that line take the most of the loop run time .What should I do to make the program go faster ?
Added after 18 minutes:
I need some suggestions
I am working on a small program .This program is to show info on a QTableWidget , it may have thousand rows , but the main time waste section is a loop , code like below :
int i=0;
vector<Case>::iterator it = tmp.begin();
for(;it!=tmp.end();it++, i++)
{
table->insertRow(i);
table->setCellWidget( i, 0, new QCheckBox(QString("Y/N")));
table->setItem(i, 1, new QTableWidgetItem(((*it).type)));
table->setItem(i, 2, new QTableWidgetItem(QString((*it).name.c_str())));
table->setItem(i, 3, new QTableWidgetItem(QString((*it).note.c_str())));
}
If I delete the line "table->setCellWidget( i, 0, new QCheckBox(QString("Y/N")));" ,the program will go much more faster ,so that line take the most of the loop run time .What should I do to make the program go faster ?
Added after 18 minutes:
I need some suggestions