qt - How to get the text of a combobox in a tablewidget? -


i’m new qt, need getting value of combobox in table widget.

i use “setcellwidget” add combobox(in case, name “settinga”) table widget (the name “tablewidget_4”):


qcombobox* settinga = new qcombobox();   settinga->additem("100"); settinga->additem("200");  ui->tablewidget_4->setcolumncount(1); ui->tablewidget_4->setrowcount(3); ui->tablewidget_4->setcellwidget ( 0, 0, settinga ); 

what want here is: when button (its name “applycombobutton” in case) clicked, want value of combobox(settinga) can saved qstringlist(inputcombodata) , , how try this:


void mainwindow::on_applycombobutton_clicked() {  qstringlist inputcombodata;   inputcombodata << ui->tablewidget_4->item(0,0)->text();  }   

and fails. how can value of combobox?

you can use qtablewidget::cellwidget ( int row, int column ) function qcombobox widget. use qobject_cast cast qcombobox, , use currenttext() function text.

qcombobox *mycb = qobject_cast<qcombobox*>(ui->tablewidget_4->cellwidget(0,0)); inputcombodata << mycb->currenttext(); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -