[Development] Usage of Q_OBJECT macro in QObject subclasses that don't use signals, slots, or properties

Curtis Mitch mitch.curtis at theqtcompany.com
Mon Mar 7 21:21:54 CET 2016


Thanks guys.

Is this worth mentioning in the documentation?

________________________________________
From: Development <development-bounces+mitch.curtis=theqtcompany.com at qt-project.org> on behalf of Giuseppe D'Angelo <giuseppe.dangelo at kdab.com>
Sent: Monday, 7 March 2016 21:19
To: development at qt-project.org
Subject: Re: [Development] Usage of Q_OBJECT macro in QObject subclasses that don't use signals, slots, or properties

Il 07/03/2016 20:55, Curtis Mitch ha scritto:
> Why is this the case? What strange behaviour could result from not doing so?

qobject_cast breaks; the meta object system reports and uses the wrong
class name (so things like "inherits", "className" etc. don't work);
tr() uses the wrong context; and so on.

qobject_cast breakage may be serious enough to justify an automatic -1
to all public QObjects-without-Q_OBJECT classes.

Cheers,
--
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - The Qt Experts




More information about the Development mailing list