If you want signal/slot support for graphics items, you could use QGraphicsObject instead of QGraphicsItem
. This would allow you to emit customs signals, like this:
class Node(QtGui.QGraphicsObject):
customSignal = QtCore.pyqtSignal(str)
...
@QtCore.pyqtSlot()
def notifyaction(self):
message = 'action1'
self.customSignal.emit(message)
To receive these custom signals, just connect an appropriate handler:
item.customSignal.connect(scene.handleCustomSignal)
However, it may be simpler to avoid signals altogether and just call the scene directly. Every graphics item can access the scene its been added to via its scene method. So you could just do something as simple as this:
@QtCore.pyqtSlot()
def notifyaction(self):
message = 'action1'
scene = self.scene()
if scene is not None:
scene.handleItemAction(self, message)
And doing things this way means you don't have to connect up signals for every graphics item that is created.