If you use qobject_cast, there is really no point in comparing class names yourself using QMetaObject::className(). Just make the cast and see if resulting pointer is null or not. And remember meta-object for a class is only generated if the class contains the Q_OBJECT macro.
Bookmarks