...QString name(obj->metaObject()->className());if ( name == "MyLabel" ) { <do_something> return;}if ( name == "QLabel" ) { <do_something_else> return;}...
typeid(_MY_OBJECT_)
typeid(ИМЯ_ТИПА)
#include<typeinfo>...MyLabel *lb;QLabel *label;...void BlaClass::doIt(QObject *o){ if(typeid(o)==typeid(QLabel)){ // do something } else if(typeid(o)==typeid(MyLabel)){ // do something } else{ // what a fuck?! }}
Q_DECLARE_METATYPE(MyType)struct MyType{ int id; QString str;};qRegisterMetaType<MyType>("MyType");QVariant var = index.data(Qt::UserRole);if ( var.canConvert<MyType>() ){MyType mt = var.value<MyType>();model->setData(index, QVariant(qVariantFromValue(mt)), Qt::UserRole);}else ...