GridLayout Help
-
wrote on 31 Dec 2020, 14:00 last edited by
Hello there,
I'm using GridLayout for the first time and looking to create a simple Dlg:
grid_layout = QGridLayout() grid_layout.addWidget(self._info_lbl, 0, 0, rowSpan=2, columnSpan=3) grid_layout.addWidget(QLabel("name: "), 2, 0, rowSpan=1, columnSpan=1) grid_layout.addWidget(self._name_txt, 2, 1, rowSpan=1, columnSpan=2) grid_layout.addWidget(QLabel("type: "), 3, 0, rowSpan=1, columnSpan=1) grid_layout.addWidget(self._types_cmb, 3, 1, rowSpan=1, columnSpan=2) grid_layout.addWidget(self._button_box, 4, 0, rowSpan=1, columnSpan=3) self.setLayout(grid_layout)
However, the problems are:
- I was expecting the label in the first row to be allocated 2 rows, but it only uses one
- the LineEdit and Combo are on the far right of the layout and only appear to be taking up one column
- I would like to add a margin / space between the buttons and the above controls. What's the best approach for this?
Could anyone point me in a direction for a good tutorial on GridLayout and spanning / SizePolicy, so I can understand this better.
Much appreciated,
Marcus -
Hi,
Can you provide a minimal runnable script that shows that behaviour ?
Which version of PyQt/PySide are you using ?
2/2