[PyQt] inheriting from QObject and dbus.service.Object

Phil Thompson phil at riverbankcomputing.com
Tue Aug 11 09:21:37 BST 2009


On Tue, 11 Aug 2009 07:54:35 +0200, Marcos Dione <mdione at grulic.org.ar>
wrote:
> I'm trying to export some class' methods via DBus. this class is already
a 
> subclass of QObject, so I thought that simply adding inheritance on 
> dbus.service.Object would work. but it doesn't; I get this error:
> 
> In [2]: import dbus.service
> 
> In [5]: from PyQt4.QtCore import QObject
> 
> In [8]: class A (dbus.service.Object, QObject): pass
> TypeError: Error when calling the metaclass bases
>     metaclass conflict: the metaclass of a derived class must be a
>     (non-strict)
>     subclass of the metaclasses of all its bases
> 
>     I tried figuring out which are the metaclasses. it was easy for 
> dbus.service.Object, but no cigar with QObject:
> 
> 
> In [4]: dbus.service.Object.__metaclass__
> Out[4]: <class 'dbus.service.InterfaceType'>
> 
> In [6]: QObject.__metaclass__
> AttributeError: type object 'QObject' has no attribute '__metaclass__'
> 
>     is it possible to inherit from both? or will I have to make another
>     class
> for this?

You can't inherit from both for the reason given. I don't know enough about
DBus to know what the best solution is.

Phil


More information about the PyQt mailing list