在设定完QGridlayout布局内容后,将layout传入下述函数,即可实现行列宽高设定基本符合需求。
def gridLayoutSet(self
, layout
):
rowSize
= 100
colSize
= 100
for row
in range(layout
.rowCount
()):
layout
.setRowStretch
(row
, 1)
layout
.setRowMinimumHeight
(row
, rowSize
)
for col
in range(layout
.columnCount
()):
layout
.setColumnStretch
(col
, 1)
layout
.setColumnMinimumWidth
(col
, colSize
)
参考文献: [1] Qt官网-QGridLayout