qobject_cast won't work because CompView is not a QObject. dynamic_cast seems to work.