PDA

View Full Version : question about inheritance



adamatic
16th February 2009, 11:04
Hello.

I have a question about inheritance.

I was having an error with vtable telling:
Undefined reference to vtable .....

I checked in the forum about this and i found that the Q_OBJECT had to be included. I had it included in the clases which inherit from the base class, but not in the base class.

I included the Q_OBJECT in the base class and it is working now. I would like to know the reason, is there a rule which specify that the base class have to include the Q_OBJECT if any of its descendats need it?

Thank you in advanced.

talk2amulya
16th February 2009, 11:32
QT uses a system known as meta-object system. Any QT class which is derived, directly or indirectly from QObject has to have Q_OBJECT macro! it includes a lot of functions that will only be defined if this macro is there..