Search code examples
pyqt5qgridlayoutqsplitter

PYQT5: How to set splitter to a grid layout?


I want to add a grid of plots to a splitter. I know how to set vertical (QSplitter(Qt.Vertical)) and horizontal (QSplitter(Qt.Horizontal)) layouts to a splitter but not sure how to make it in grid layout.


Solution

  • I figured it out like this:

    self.plot_splitter = QSplitter(Qt.Vertical)
    
    self.plot_grid = QGridLayout()
    self.plot_widget = QWidget()
    self.plot_widget.setLayout(self.plot_grid)
    
    self.plot_splitter.addWidget(self.plot_widget)