[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Problem connecting signal and slot between a QGraphicsItem
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2009-12-23 22:33:36
Message-ID: 1b94f0b3a288e1410b0e36accee59f81 () localhost
[Download RAW message or body]
On Wed, 23 Dec 2009 11:17:14 -0800 (PST), dizou <di_zou@yahoo.com> wrote:
> I have a class that inherits the QGraphicsItem and QObject. In the
> mousePressEvent() function, it emits a signal. I want to connect this
> signal
> with a function in the QGraphicsItem's QGraphicsScene. This is what I
have:
>
> class DisplayItem(QGraphicsItem, QObject):
> def __init__(self):
> QGraphicsItem.__init__(self)
> QObject.__init__(self)
> def mousePressEvent(self, event):
> self.update()
> self.emit(SIGNAL("updateItemSelected()"))
> QGraphicsItem.mousePressEvent(self, event)
>
> class DisplayScene(QGraphicsScene):
> def __init__(self, parent):
> QGraphicsScene.__init__(self, parent)
> def DisplayChildren(self, item, graphViews, x, y):
> dispItem = item.GetDisplayItem() #This returns a DisplayItem()
> object
> dispItem.setGraphView(graphViews[0])
> dispItem.setPos(x, y)
>
> self.connect(dispItem, SIGNAL("updateItemSelected()"),
> self.ItemSelected)
> self.addItem(dispItem)
>
> When I run this and call the DisplayScene.DisplayChildren() function, I
get
> this error:
> self.connect(dispItem, SIGNAL("updateItemSelected()"), self.ItemSelected)
> SystemError: error return without exception set
PyQt doesn't support sub-classing from two wrapped classes. PyQt v4.7 will
raise an exception if you try.
If you are using Qt v4.6 then sub-class from QGraphicsObject instead.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic