[PyQt] Problem connecting signal and slot between a QGraphicsItem and QGraphicsScene

dizou di_zou at yahoo.com
Wed Dec 23 19:17:14 GMT 2009


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
-- 
View this message in context: http://old.nabble.com/Problem-connecting-signal-and-slot-between-a-QGraphicsItem-and-QGraphicsScene-tp26906068p26906068.html
Sent from the PyQt mailing list archive at Nabble.com.



More information about the PyQt mailing list