San_4368
21st December 2017, 08:14
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.
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++;
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();
}
Kindly help me
thanks in advance..
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.
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++;
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();
}
Kindly help me
thanks in advance..