Hello Luke,
I've been working with Qgraphics (view/scenes/items) for the past weeks. Currently I'm trying to add some nice dynamic graphs to my application using Pyqtgraph. My current application plots other QGraphicsItems, a timeline, some blocks etc on a QgraphicsScene, now I simply want to include a Pyqt graph showing data, title axis etc. to this scene. I figured this simple example would work:
class ExampleDialog(QDialog):
def __init__(self,parent=None):
super(ExampleDialog,self).__init__(parent)
layout=QHBoxLayout()
self.setLayout(layout)
self.scene = QGraphicsScene()
self.view= QGraphicsView()
self.view.setDragMode(QGraphicsView.ScrollHandDrag) #so we can move around if we increase size of scene
self.view.setScene(self.scene)
layout.addWidget(self.view)
self.plt1=pg.PlotWidget() # or pg.PlotItem()
self.createHist() #custom function to plot some data on plt1
self.scene.addWidget(self.plt1) #or .addItem(self.plt1)
Now, if I use a PlotWidget the scroll behavior is incorrect, sometimes the wheel event is picked up, sometimes it zoomes only horizontally or vertically, or it doesn't react at all, depending on where you are with your mouse in the plot. If I add a PlotItem, the wheel event is only picked up by the axis, but it's not translated to the graph. Also, dragging doesn't work.
Am I doing something wrong/approaching this in the wrong way? Is there some work around? Or are the Pyqtgraphs 'graphs' commonly not mixed with normal Qgraphicscenes and items?
ps. sorry if I posted the message in a wrong place, not really used to google...:)
Op dinsdag 22 juli 2014 16:53:47 UTC+2 schreef Luke Campagnola: