Python Forum

Full Version: QGridLayout and stretching widgets when maximized
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a QGridLayout set with 2 rows and 2 columns. Column 0 spans 2 rows, column 1 has a QTableView in row 0 and a image (QLabel) in row 1. When I maximize the screen, I want the widgets in column 1 to expand to fill the screen. They don't though. I have set
grid.setColumnStretch(1, 400) and set each widget to be sized based on setMinimumSize(). The sizePolicy() is Preferred for both horizontal and vertical.

Anyone have any ideas as to why they don't expand? It is all housed in a QMainWindow with a frame as the central widget and the grid layout has that frame as its parent.
I figured it out. When I wrote this, I forgot there was an extra, empty column at the end of the grid. By making my widgets span that empty column, and setting the stretch (as I correctly understood it), all is good.

Qt works as expected. Or should as I say as I understand it to. If there is a fault, it will be in my understanding.