如何使用QGraphicsScene正确显示QChart?

时间:2019-04-01 12:24:27

标签: python pyqt pyqt5 qgraphicsscene qchart

我想使用QGraphicsScene和QGraphicsView在GUI中显示QChart。我尝试如下进行操作:

chart = QChart()
chart.addSeries(series)        
scene = QGraphicsScene()
scene.setSceneRect(MyGraphicsView.sceneRect())
scene.addItem(chart)
MyGraphicsView.setScene(scene)

问题在于图表未调整为场景大小,而是显示在其角落。我知道,我可以使用QChartView,但是我已经在我的应用程序的许多地方使用了QGraphicsScene,并且希望以这种方式使用它。

谢谢您的建议。

enter image description here 场景几乎占据了中间的整个灰色区域,而图表仅占据了其中的一小部分。

0 个答案:

没有答案