How can i get the current text of Qcombobox in QtableWidget
How can i get the current text of Qcombobox in QtableWidget
use the combobox.currentText() method.
it is not working because it is in the QtableWidget
can u post the code snippet in question ?
int row=1;
int col=8;
QComboBox *com=new QComboBox(this);
com->addItems(dislist);
ui->widget->setCellWidget(row,col,com);
Note:
ui->widget - is QtableWidget,
then how can i get the currentText in the Qcombobox
Pls help me
Thank U
Exactly the same way you do anywhere else, by using a pointer to the control:
You have to keep a pointer to the control to be able to do this.
Or (if you know what you are doing) you can use QTableWidget::cellWidget(), cast it to QComboBox and then use currentText(). But this may cause disaster when used incorrectly...
Ginsengelf
i want to get the text of combobox in another function.
can u pls explain me.
How to code this
Check this out
Qt Code:
int row = 1; int col = 8; QStringList dislist; com->addItems(dislist); ui->widget->setCellWidget(row, col, com); //another function QString text; if(cell_com != 0) { text = cell_com->currentText(); }To copy to clipboard, switch view to plain text mode
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
its working !
Thank U, Thank U,Thank U very much......
Bookmarks