Reputation: 189
I don't konw if my method is the right method, but it works.
class PltItem(pg.PlotItem):
pltClicked = Signal()
def __init__(self, parent = None):
super(PltItem, self).__init__(parent)
def mousePressEvent(self, ev):
super(PltItem, self).mousePressEvent(ev)
self.pltClicked.emit()
the in the main window i use
for i, plt in enumerate(self.plts):
self.connect(plt, SIGNAL("pltClicked()"), partial(self.selectplot, i))
def selectplot(self, i):
...
Upvotes: 0
Views: 4082
Reputation: 11644
Your solution is a good one. Another solution is to connect to the GraphicsScene.sigMouseClicked signal and use QGraphicsScene.items() to determine whether a PlotItem (or any other item) was under the click.
Upvotes: 3