Hi,
I read a text (csv) file to populate a QTableWidget. The first row contains QComboBox in all the columns. I see that when I do not add any combo box, the table is populated very quickly whereas when I add combo box, it takes a very long time for the table to get populated.
Is there a solution to this?
Here is the code:
void TextFileImporter
::importData(const QStringList &lineList
) {
dataTable->setRowCount(lineList.count()+1);
for(int i = 0; i < lineList.count(); ++i){
for(int j = 0; j < columnList.count(); ++j){
if(dataTable->columnCount() == 0){
dataTable->setColumnCount(columnList.count());
}
if(i == 0){
dataTable->addFieldCombo(j);//If comment this line then things are very fast
}
QString cellString
= columnList.
at(j
);
cellString.remove("\"");
dataTable->insertItemAt(i+1,j,cellString);
}
}
}
void DataTable::addFieldCombo(const int column)
{
populateFieldCombo(fieldCombo);//This line is not making much a difference
setCellWidget(0,column,fieldCombo);
}
void TextFileImporter::importData(const QStringList &lineList)
{
dataTable->setRowCount(lineList.count()+1);
for(int i = 0; i < lineList.count(); ++i){
QStringList columnList = lineList.at(i).split(",");
for(int j = 0; j < columnList.count(); ++j){
if(dataTable->columnCount() == 0){
dataTable->setColumnCount(columnList.count());
}
if(i == 0){
dataTable->addFieldCombo(j);//If comment this line then things are very fast
}
QString cellString = columnList.at(j);
cellString.remove("\"");
dataTable->insertItemAt(i+1,j,cellString);
}
}
}
void DataTable::addFieldCombo(const int column)
{
QComboBox *fieldCombo = new QComboBox(this);
populateFieldCombo(fieldCombo);//This line is not making much a difference
setCellWidget(0,column,fieldCombo);
}
To copy to clipboard, switch view to plain text mode
In the debug window I get the following message (lots of time)
QComboBox::setProperty("text", value) failed: property invalid, read-only or does not exist
Any Idea?
Bookmarks