Python Forum
[PyQt] QGridLayout and stretching widgets when maximized
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QGridLayout and stretching widgets when maximized
#1
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.
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QGridLayout, QProgressBar bar fills widgets shrink malonn 5 1,620 Nov-23-2022, 05:30 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020