문제

A simple QtGui.QListWidget is placed inside of a QtGui.QFormLayout.

This list widget's sides are beautifully stick to the side edges of the main dialog box but not to the dialog's bottom or top edge. The list widget re-sizes itself only when a main dialog window gets wider or slimmer and not when it gets taller and shorter.

How can we make a widget placed inside of QFormLayout stick to the bottom edge of the dialog window?

도움이 되었습니까?

해결책

Use QSizePolicy.setVerticalStretch:

import PyQt4.QtGui as gui

app = gui.QApplication([])

w = gui.QWidget()

la = gui.QFormLayout()
w.setLayout(la)

tw = gui.QTreeWidget()
sp = tw.sizePolicy()
sp.setVerticalStretch(1)
tw.setSizePolicy(sp)

la.addWidget(tw)

w.show()

app.exec_()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top