[PyQt] GraphicsItem, QObject Inheritance problem

Jason H scorp1us at yahoo.com
Thu Oct 1 15:09:07 BST 2009


Thanks Brian, but I don't understand that. If it is derived from a non-object, how does the connect work?

I went with the reverse approach: 
class ObjWrapper(QObject):
    def __init__(self, item):
        QObject.__init__(self)
        self.item=item
... then provide the properties, signals/slots, which all operate on self.item ...

It would be handy if these approaches were discussed in the docs.



________________________________
From: Brian Kelley <kelley at eyesopen.com>
To: Jason H <scorp1us at yahoo.com>
Cc: "pyqt at riverbankcomputing.com" <pyqt at riverbankcomputing.com>
Sent: Thursday, October 1, 2009 8:16:52 AM
Subject: Re: [PyQt] GraphicsItem, QObject Inheritance problem

Re: [PyQt] GraphicsItem, QObject Inheritance problem What you can do, however, is to make a QObject delegate like:

class WrappedAffineItem(AffineItem):
       def __init__(self ...):
           self.qobject = QObject(self)
           AffineItem.__init__(self, ..., parent)
           self.qobject.connect(self.qobject, 
                                SIGNAL("mysignal(int)",
                                SLOT(self.dosomething))

       def connect(self, *a, *kw):
           self.qobject.connect(*a,**kw)

       def soSomething(self, *a):
           pass

Brian Kelley 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20091001/d9a980e2/attachment.html


More information about the PyQt mailing list