qobject_cast is times faster dynamic_cast for objects that inherit QObject. also, use auto keyword to not duplicate class names.