[Qt-interest] Inheritance limitations

Malyushytsky, Alex alex at wai.com
Tue Oct 13 01:02:59 CEST 2009


And inheritance from multiple QObject derived classes is not supported either.

>> If you are using multiple inheritance, moc assumes that the first inherited class is a subclass of QObject. Also, be sure that only the first inherited class is a QObject.

Key word here is:  the first inherited class is a subclass of QObject ( it does not have to be QObject )

Regards,
   Alex


From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Jason H
Sent: Monday, October 12, 2009 3:02 PM
To: Scott Sibley; qt-interest at trolltech.com
Subject: Re: [Qt-interest] Inheritance limitations

If A inherits QObject, why inherit it again?

class B: public A {
    Q_OBJECT
};

Is all you should need. Right?

________________________________
From: Scott Sibley <sisibley at gmail.com>
To: qt-interest at trolltech.com
Sent: Mon, October 12, 2009 5:31:46 PM
Subject: [Qt-interest] Inheritance limitations

I get the following warning with these two classes. I think I'm learning to cope with it (I'm rewriting a pygtk app in C++ and QT, where I just dropped signals wherever I liked), but was curious why there's the limitation.

[starlon at localhost tmp]$ moc-qt4 -I/usr/include/QtCore -o moc_test.cc<http://moc_test.cc> test.h
test.h:11: Warning: Class B inherits from two QObject subclasses QObject and A. This is not supported!

// test.h
class A: public virtual QObject {
    Q_OBJECT
};

class B: public virtual QObject, public A {
    Q_OBJECT
};




---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091012/639eba17/attachment.html 


More information about the Qt-interest-old mailing list