diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index a54690606a..0b6c65ef95 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -156,13 +156,17 @@ public: template inline T findChild(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const - { return static_cast(qt_qFindChild_helper(this, aName, reinterpret_cast(0)->staticMetaObject, options)); } + { + typedef typename QtPrivate::remove_cv::type>::type ObjType; + return static_cast(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options)); + } template inline QList findChildren(const QString &aName = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { + typedef typename QtPrivate::remove_cv::type>::type ObjType; QList list; - qt_qFindChildren_helper(this, aName, reinterpret_cast(0)->staticMetaObject, + qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); return list; } @@ -171,8 +175,9 @@ public: template inline QList findChildren(const QRegExp &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { + typedef typename QtPrivate::remove_cv::type>::type ObjType; QList list; - qt_qFindChildren_helper(this, re, reinterpret_cast(0)->staticMetaObject, + qt_qFindChildren_helper(this, re, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); return list; } @@ -182,8 +187,9 @@ public: template inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { + typedef typename QtPrivate::remove_cv::type>::type ObjType; QList list; - qt_qFindChildren_helper(this, re, reinterpret_cast(0)->staticMetaObject, + qt_qFindChildren_helper(this, re, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); return list; } @@ -519,7 +525,7 @@ inline T qobject_cast(QObject *object) typedef typename QtPrivate::remove_cv::type>::type ObjType; Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); - return static_cast(reinterpret_cast(object)->staticMetaObject.cast(object)); + return static_cast(ObjType::staticMetaObject.cast(object)); } template @@ -528,7 +534,7 @@ inline T qobject_cast(const QObject *object) typedef typename QtPrivate::remove_cv::type>::type ObjType; Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); - return static_cast(reinterpret_cast(object)->staticMetaObject.cast(object)); + return static_cast(ObjType::staticMetaObject.cast(object)); }