On Mon, Mar 07, 2016 at 07:55:11PM +0000, Curtis Mitch wrote:
> Recently I noticed this sentence in QObject's documentation [1]:
> 
> We strongly recommend the use of this macro in all subclasses of QObject 
> regardless of whether or
> not they actually use signals, slots and properties, since failure to do so 
> may lead certain
> functions to exhibit strange behavior.
> 
> Why is this the case?

> What strange behaviour could result from not doing so?

Behaviour from not adding Q_OBJECT to classes is well-defined. Whether
the result can be considered "strange" is subjective. Documenting
behaviour as "strange" is what appears strange to me.

IMNSHO the advice to add Q_OBJECT to user code even if not needed
is plainly bad as doing so adds compile time and code size overhead.

For Qt's own classes it makes sense to a certain degree to e.g. allow 
qobject_cast in potential user code uniformly.

For normal applications *using* Qt that know their needs adding
unnecessary Q_OBJECTs is likely to be as beneficial as snake oil.

Andre'
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to