[PyQt] adding signalling to QGraphicsItems
Phil Thompson
phil at riverbankcomputing.com
Thu Jul 1 11:29:12 BST 2010
On Thu, 01 Jul 2010 11:58:01 +0200, "Christopher M. Nahler"
<christopher.nahler at papermodels.at> wrote:
> I want to add signalling functionality to scene items. In my case they
> are usually QGraphicsRectItems..
>
> I thought I could do this with deriving from QGraphicsObject but then I
> loose all the funtionality for the rectangle, handling pens and brushes,
> shapes etc.
>
> Isn't it easier to just derive from QGraphicsRectItem and QObject? Or
> should I derive from QGraphicsRectItem and QGraphicsObject instead?
Neither. You can't multiply inherit from more than one PyQt class.
> Or are there any other ways to do this?
Create a QObject subclass that implements your signals as an attribute of
your QGraphicsRectItem.
Phil
More information about the PyQt
mailing list