Hello All,
I have created a Qcombobox as a Qwidget in a QtableWidget and it is working fine, The below code i have used for creating combobox in table widget.
pLayout1->addWidget(ipcombo);
pLayout1->setAlignment(Qt::AlignCenter);
pLayout1->setContentsMargins(0,0,0,0);
pWidget1->setLayout(pLayout1);
ipcombo->addItem("YES");
ipcombo->addItem("NO");
ui->tableWidget->setCellWidget(1,3,pWidget1);
connect(ipcombo,
SIGNAL(currentIndexChanged
(QString)),
this,
SLOT(on_currentIndexChanged
(QString)));
index++;
QWidget *pWidget1 = new QWidget();
QComboBox *ipcombo = new QComboBox;
QHBoxLayout * pLayout1 = new QHBoxLayout(pWidget1);
pLayout1->addWidget(ipcombo);
pLayout1->setAlignment(Qt::AlignCenter);
pLayout1->setContentsMargins(0,0,0,0);
pWidget1->setLayout(pLayout1);
ipcombo->addItem("YES");
ipcombo->addItem("NO");
ui->tableWidget->setCellWidget(1,3,pWidget1);
connect(ipcombo, SIGNAL(currentIndexChanged(QString)),this,SLOT(on_currentIndexChanged(QString)));
index++;
To copy to clipboard, switch view to plain text mode
now the problem is i couldn't get the data out of the combobox which is assigned as a cellwidget. the below code only am using to get the data. if the button is clicked the SIGSEGV segmentation fault error is happening.
void MainWindow::on_submitbtn_2_clicked()
{
QStringlist ComboData;
QComboBox *myCB
= qobject_cast<QComboBox
*>
(ui
->tableWidget_2
->cellWidget
(row,
3));
Combodata<< myCB->currentText();
}
void MainWindow::on_submitbtn_2_clicked()
{
QStringlist ComboData;
QComboBox *myCB = qobject_cast<QComboBox*>(ui->tableWidget_2->cellWidget(row,3));
Combodata<< myCB->currentText();
}
To copy to clipboard, switch view to plain text mode
Kindly help me
thanks in advance..
Bookmarks