diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 76863d66bcf..6fe575f29ec 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -148,6 +148,8 @@ public: T findChild(QAnyStringView aName, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { typedef typename std::remove_cv::type>::type ObjType; + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, + "No Q_OBJECT in the class passed to QObject::findChild"); return static_cast(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options)); } @@ -155,6 +157,8 @@ public: QList findChildren(QAnyStringView aName, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { typedef typename std::remove_cv::type>::type ObjType; + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, + "No Q_OBJECT in the class passed to QObject::findChildren"); QList list; qt_qFindChildren_helper(this, aName, ObjType::staticMetaObject, reinterpret_cast *>(&list), options); @@ -178,6 +182,8 @@ public: inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { typedef typename std::remove_cv::type>::type ObjType; + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, + "No Q_OBJECT in the class passed to QObject::findChildren"); QList list; qt_qFindChildren_helper(this, re, ObjType::staticMetaObject, reinterpret_cast *>(&list), options);