[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: A New Krazy Checker for Classes Requiring Q_OBJECT
From: Thorsten_Röder <thorsten.roeder () weihenstephan ! org>
Date: 2007-05-11 13:41:28
Message-ID: 11D8B651-8F4E-4536-8890-2691C99F41E9 () weihenstephan ! org
[Download RAW message or body]
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?
>>
>> Toma
>
> The test only checks direct derivation from QObject. If you don't
> need any
> of the Meta Object features (properties, signals, slots, enums,
> className,
> 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
> shouldn't
> 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
> derivation.
[1] recommends the use the Q_OBJECT macro for all subclasses of
QObject too:
"While it is possible to use QObject as a base class without the
Q_OBJECT macro
and without meta-object code, neither signals and slots nor the other
features
described here will be available if the Q_OBJECT macro is not used.
From the
meta-object system's point of view, a QObject subclass without meta
code is
equivalent to its closest ancestor with meta-object code. This means
for example,
that QMetaObject::className() will not return the actual name of your
class, but
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
signals, slots,
and properties."
[1] http://doc.trolltech.com/4.3/metaobjects.html
Thorsten
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic