I'm setting up a custom PlotDataItem to recieve mouseDragEvents. I've adjusted this answer to my needs. For now I've just added a simple setData to the event to check if it's working. The custom PlotDataItem is as:
class CustomPlotItem(pg.PlotDataItem):
def __init__(self, *args, **kargs):
super().__init__(*args, **kargs)
def setParentItem(self, parent):
super().setParentItem(parent)
self.parentBox = self.parentItem().parentItem()
def mouseDragEvent(self, ev):
if ev.button() != QtCore.Qt.LeftButton:
ev.ignore()
return
if ev.isStart():
if self.parentBox.curveDragged != None or not self.mouseShape().contains(ev.pos()):
ev.ignore()
return
self.parentBox.curveDragged = self
elif ev.isFinish():
self.parentBox.curveDragged = None
return
elif self.parentBox.curveDragged != self:
ev.ignore()
return
self.setData([40,50,60,200],[20,50,80,500])
ev.accept()
The PlotDataItem is added to a custom ViewBox this implements curveDragged, so I know which curve is being dragged, if any. I've also disabled the ViewBox's mouseDragEvents for debugging purposes.
However when try to drag the line in the ViewBox, nothing happens. Also if I add an exception at the top of the mouseDragEvent nothing happens. This leads me to believe mouseDragEvent is not being called at all.
Im using Python 3.3 (Anaconda Distribution) and the develop version (0.9.9) of pyqtgraph.
I hope someone can help me with this :). Thanks in advance.