[Qt-interest] void value not ignored as it ought to be
Rohan McGovern
rohan.mcgovern at nokia.com
Fri Mar 27 00:01:22 CET 2009
On Friday 27 March 2009, ext Andrea Franceschini wrote:
> 2009/3/26, Thiago Macieira <thiago.macieira at trolltech.com>:
> > Does the Doodle::PadWidget class have a Q_OBJECT macro?
>
> Nope. Adding it seems to have fixed the problem. I thought that a
> class could safely inherit the expansion of Q_OBJECT but it seems
> I'm wrong. Probably I'm missing something about the Moc, right?
If you have a class Widget which has Q_OBJECT, and a subclass
PadWidget which does not have Q_OBJECT, then PadWidget has the same
metaobject as Widget. In other words, the metatype system sees all
PadWidget instances as Widgets.
In some situations that's appropriate, so one could say a class
can "safely inherit the expansion of Q_OBJECT". However as you
discovered, qobject_cast requires the target class to have its own
unique metaobject.
--
Rohan McGovern
Qt Software, Nokia
More information about the Qt-interest-old
mailing list