QObjects on interfaces

Manuel Breugelmans mbr.nxi at gmail.com
Fri Jul 25 12:10:21 UTC 2008


On Friday 25 July 2008 13:47:38 Kris Wong wrote:
> > class IFoo : public QObject {};
> > class IBar : public QObject {};
> > class FooBar : public IFoo, public IBar {}; // this is now impossible.
>
> That is not true.  C++ isn't java. ;)

It is illegal ;) That is one of those Qt specific limitations (along with 
QObject template classes). It will generate a moc error, just try that snippet 
above.

'''foobar.h:3: Warning: Class FooBar inherits from two QObject subclasses IFoo 
and IBar. This is not supported!""

cfr http://doc.trolltech.com/qq/qq15-academic.html

> http://www.parashift.com/c++-faq-lite/multiple-inheritance.html#faq-25.8
>
> class IFoo : public virtual QObject {};
> class IBar : public virtual QObject {};
> class FooBar : public IFoo, public IBar {};  // works like a charm
>
> Kris Wong
>
> _______________________________________________
> KDevelop-devel mailing list
> KDevelop-devel at kdevelop.org
> https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel





More information about the KDevelop-devel mailing list