QObjects on interfaces

Manuel Breugelmans mbr.nxi at gmail.com
Fri Jul 25 11:32:38 UTC 2008


On Friday 25 July 2008 13:19:52 Aleix wrote:
> On 7/25/08, Manuel Breugelmans <mbr.nxi at gmail.com> wrote:
> > On Friday 25 July 2008 00:19:01 Aleix wrote:
> >  > Hi kdevelopers,
> >  >
> >  > I know it is a discussion that has raised sometimes on the IRC and on
> >  > the hackaton but it is something important enough to be discussed
> >  > here.
> >  >
> >  > As you might know, I'm working on the KDevPlatform Kross support and,
> >  > for Kross it is necessary that an Object, to be recognized, inherits a
> >  > QObject to retrieve the methods it has.
> >  >
> >  > When I have a non-QObject class, I have 2 alternatives if I want it to
> >  > be called from a script:
> >  >
> >  > make it a QObject (as I did in the patch attatched)
> >  > -or-
> >  > make a wrapper as I did in kross/projectitemadaptors.h
> >  >
> >  > I think it is much better to get it from the QObject because we don't
> >  > duplicate any code but I also understand that in cases where it is
> >  > just heavy to use a QObject so...
> >  >
> >  > Note: the attatched patch is just an example of how things change when
> >  > I make it QObject, I don't mean it is the only cases I need that.
> >  >
> >  > Any thoughts?
> >  >
> >  > Thank you,
> >  > Aleix
> >
> > Imo the biggest problem with using QObject when it's not needed is
> > multiple inheritance. Inheriting 2 QObjects is a no-go, so in java terms
> > this effectivly changes interfaces into abstract classes.
>
> ???
> 2 QObjects? If it already inherits QObject you don't have to add it
> anymore.
>

errrr, ok probably I didnt explain clearly:

class IFoo : public QObject {};
class IBar : public QObject {};
class FooBar : public IFoo, public IBar {}; // this is now impossible.

So if this is changed on too much interfaces, things will break. But maybe you 
weren't intending to add this on interfaces in the first place?


Manuel




More information about the KDevelop-devel mailing list