Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
6.3.1
-
None
Description
QObject::findChildren<T*> returns an unexpected result, if the Q_OBJECT macro is missing in the declaration of T.
In the attached example the Q_OBJECT macro is commented out from the declaration of class Derived (derived from QObject). In the first step 5 children of class QObject and 5 children of class Derived are created for the application object. In the second step the children of class Derived shall be deleted. But instead all children are deleted, even the event dispatcher.
Reason for that behaviour is, that QObject::findChildren uses the Qt's meta-object system and the kind, how the meta-object system works. Because this is somehow a time bomb (a Q_OBJECT macro could be removed accidently), QObject::findChildren should use 'dynamic_cast' instead.