[Qt-interest] Inheritance limitations

Mihail Naydenov mlists at ymail.com
Tue Oct 13 07:48:51 CEST 2009


Hi, you should read this (about  qobjects and interface clases).
http://doc.trolltech.com/qq/qq15-academic.html

MihailNaydenov


>
>From: Scott Sibley <sisibley at gmail.com>
>To: Jason H <scorp1us at yahoo.com>
>Cc: qt-interest at trolltech.com
>Sent: Tue, October 13, 2009 2:02:04 AM
>Subject: Re: [Qt-interest] Inheritance limitations
>
>
>Probably true. I just thought of a solution to my issue though. You see, I needed a QObject slot, but a different method for each different class deriving A. So the following might do it.
>
>class A: public QObject { // The reason A needs to be a QObject is I have some properties for QScript to access.
>>    Q_OBJECT
>
>    public slots:
>    void aMethod();
>};
>
>class B: public A {
>    public:
>    void aMethod(); // Class C would provide its own aMethod as well.
>}
>
>Of course I haven't tested this yet. I don't see why it wouldn't work.
>
>
>On Mon, Oct 12, 2009 at 5:01 PM, Jason H <scorp1us at yahoo.com> wrote:
>
>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 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
>>};
>>
>>
>>
>>
>


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091012/cdcd3bcb/attachment.html 


More information about the Qt-interest-old mailing list