You have an qobject_cast example in the link i gave you, and it's similar with dynamic_cast (but it is supposed to be used with instances of classes derived from QObject)
QComboBox* comboFromTableWidget
= dynamic_cast<QComboBox
*>
(ui
->tableWidget
->cellWidget
(row,kol
));
if(comboFromTableWidget != 0) /*test for null pointer (dynamic_cast returns null if the pointer can't be "casted" to a pointer to a derived class)*/
{
//use the combo here... because the pointer holds an address of a QComboBox...
QString text
= comboFromTableWidget
->currentText
();
}
QComboBox* comboFromTableWidget = dynamic_cast<QComboBox*>(ui->tableWidget->cellWidget(row,kol));
if(comboFromTableWidget != 0) /*test for null pointer (dynamic_cast returns null if the pointer can't be "casted" to a pointer to a derived class)*/
{
//use the combo here... because the pointer holds an address of a QComboBox...
QString text = comboFromTableWidget->currentText();
}
To copy to clipboard, switch view to plain text mode
//i suggest you read a C++ book (the two volumes of Thinking in C++ can be found free of charge - just google it), else you will have a lot of problems - and Qt is actually "cute" and the saying that Qt actually brings to front the "much smaller and cleaner language" that struggle to get out from C++ is true
, but still you need pretty good C++ knowledge to enjoy using Qt framework - especially OOP <dynamic_cast is somehow OOP related
>
Bookmarks