I'm trying to embed a pyqtgraph plot in my PySide6 app but the plot is not filling the whole widget:
I want the whole PlotWidget to be filled. The PlotWidget got created with QT-Designer.
The App:
import sys
from PySide6.QtUiTools import QUiLoader
from PySide6.QtWidgets import QApplication, QMainWindow
import pyqtgraph
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.window = QUiLoader().load("test.ui", self)
self.plot_widget = pyqtgraph.PlotWidget(parent=self.window.graphicsView)
self.plot_widget.plot([1, 2, 3], [1, 2, 3])
self.window.show()
if __name__ == "__main__":
App = QApplication(sys.argv)
MW = MainWindow()
sys.exit(App.exec())
The test.ui file:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="PlotWidget" name="graphicsView"/>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<customwidgets>
<customwidget>
<class>PlotWidget</class>
<extends>QGraphicsView</extends>
<header>pyqtgraph</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
So how can I make the plot fill the whole widget?