这是我用来在窗口上布局小部件的代码:
widget = QWidget()
self.setCentralWidget(widget)
layout = QGridLayout()
map_group_box = QGroupBox()
map_group_box.setTitle('Navigation')
panel_group_box = QGroupBox()
panel_group_box.setTitle('Instrument Panel')
status_group_box = QGroupBox()
status_group_box.setTitle('Status')
layout.addWidget(map_group_box, 0, 0, 2, 1)
layout.addWidget(panel_group_box, 0, 1, 1, 1)
layout.addWidget(status_group_box, 1, 1, 1, 1)
widget.setLayout(layout)
结果如下:
我希望左列的宽度是左侧列的两倍。我如何实现这一目标?我曾尝试过QSplitters,但它们在macOS上看起来太丑了。
答案 0 :(得分:1)
:
layout.setColumnStretch(0, 2)
layout.setColumnStretch(1, 1)