May 2019
Intermediate to advanced
542 pages
13h 37m
English
Nested box layouts cover a lot of ground, but in some situations, you might like to arrange widgets in uniform rows and columns. This is where QGridLayout comes in handy. As the name suggests, it allows you to place widgets in a table-like structure.
Create a grid layout object like this:
grid_layout = qtw.QGridLayout() layout.addLayout(grid_layout)
Adding widgets to QGridLayout is similar to the method for the QBoxLayout classes, but also requires passing coordinates:
grid_layout.addWidget(spinbox, 0, 0) grid_layout.addWidget(datetimebox, 0, 1) grid_layout.addWidget(textedit, 1, 0, 2, 2)
Here are the arguments for QGridLayout.addWidget(), in order:
Read now
Unlock full access