A New Krazy Checker for Classes Requiring Q_OBJECT
thorsten.roeder at weihenstephan.org
Fri May 11 14:41:28 BST 2007
Am 11.05.2007 um 11:46 schrieb Thiago Macieira:
> Tom Albers said:
>> At Friday 11 May 2007 01:05, you wrote:
>>> Tonight's Krazy run will start looking for QObject derived classes
>>> that are without the Q_OBJECT macro. This new checker was written
>>> by Thorsten Roeder.
>> I thought that was only needed when there are signals or slots?
> The test only checks direct derivation from QObject. If you don't
> need any
> of the Meta Object features (properties, signals, slots, enums,
> qobject_cast, the meta object itself, etc.) why are you deriving from
> QObject in the first place? :-)
> QObjects are heavy: if you don't need any of those features, you
> derive from it.
> Arguably, there might be a reason to derive in the QObject hierarchy
> without including a Q_OBJECT macro, for instance to access a protected
> member function, etc. But I don't believe it exists for direct QObject
 recommends the use the Q_OBJECT macro for all subclasses of
"While it is possible to use QObject as a base class without the
and without meta-object code, neither signals and slots nor the other
described here will be available if the Q_OBJECT macro is not used.
meta-object system's point of view, a QObject subclass without meta
equivalent to its closest ancestor with meta-object code. This means
that QMetaObject::className() will not return the actual name of your
the class name of this ancestor.
Therefore, we strongly recommend that all subclasses of QObject use the
Q_OBJECT macro regardless of whether or not they actually use
More information about the kde-core-devel