Reputation: 73
I have a predefined GUI that is loaded in as a .ui file:
def __init__(self):
# Initialise main program with GUI
super(MainWindow, self).__init__()
uic.loadUi('fg_control_gui_2.ui', self)
inside that ui file I have defined a QGraphicsView, that looks as follows in the .py version of the GUI:
self.ch1_oszi_view = QtWidgets.QGraphicsView(self.centralwidget)
self.ch1_oszi_view.setGeometry(QtCore.QRect(10, 450, 361, 261))
self.ch1_oszi_view.setObjectName("ch1_oszi_view")
Now I want to add a QGraphicsScene as a canvas so I can show a plot in my GUI which is supposed to be done like this:
scene = QtWidgets.QGraphicsScene()
view = QtWidgets.QGraphicsView(scene)
My Question is now, how can I hand the scene to the previously defined QGraphicsView like it is done in the second line of code of my last example ?
Upvotes: 0
Views: 265
Reputation: 243945
You have to use the setScene()
method of QGraphicsView
:
scene = QtWidgets.QGraphicsScene()
self.ch1_oszi_view.setScene(scene)
Upvotes: 1