
Originally Posted by
ChrisW67
The example you link to is exactly the sort of thing you need to be be doing.
Hey ChrisW67,
Yes true but in that example everything is handled by QSqlTableModel class which automatically detects the queries and place the combo box where it is necessary , which is invalid in my case. My model
TableModel *newTable = new TableModel(XmlMap,this)
ui->tableView->setModel(&newTable)
ui->tableView->setItemDelegate(&comboBoxDelegate)
creating all the necessary data structure depending on the length of Xmlmap and if i put the delegate then it'll create the combo box with in all the table cell which is what i don't want.
I am thinking to switch on QTableWidget but i have much data to view and on the other hand i am thinking that TableWidget will be slow.
I have tried a simple example through QTableWidget "Quick try"
ui->tableWidget->setItem(count, columns,newItem);
columns++;
ui->tableWidget->setItem(count, columns, newItem1);
columns++;
ui->tableWidget->setItem(count, columns, newItem2);
comboBox->addItem("modeMap");
comboBox2->addItem("valueMap");
ui->tableWidget->setCellWidget(count,3,comboBox);
ui->tableWidget->setCellWidget(count,4,comboBox2);
QTableWidgetItem *newItem = new QTableWidgetItem("a");
ui->tableWidget->setItem(count, columns,newItem);
columns++;
QTableWidgetItem *newItem1 = new QTableWidgetItem("b");
ui->tableWidget->setItem(count, columns, newItem1);
columns++;
QTableWidgetItem *newItem2 = new QTableWidgetItem("c");
ui->tableWidget->setItem(count, columns, newItem2);
QComboBox* comboBox = new QComboBox();
comboBox->addItem("modeMap");
QComboBox* comboBox2 = new QComboBox();
comboBox2->addItem("valueMap");
ui->tableWidget->setCellWidget(count,3,comboBox);
ui->tableWidget->setCellWidget(count,4,comboBox2);
To copy to clipboard, switch view to plain text mode
And in last i got a good result and it is too easy to handle, but the only problem that it is taking some time to load because my xml contain 1500 rows.
New.jpg
Bookmarks