python - How to control size of widgets in Qt/PyQt/PySide grid layout -
i struck foolish annoying question. set different sizes 2 list widgets on grid layout, 1 above other. so, set 60% of form space upper widget , 40% lower widget. attempted use setrowstretch, without success.
here code:
import sys pyqt4.qtcore import * pyqt4.qtgui import * def window(): app = qapplication(sys.argv) win = qwidget() list1 = qlistview() list2 = qlistview() grid = qgridlayout() grid.setrowstretch(6, 4) grid.addwidget(list1) grid.setspacing(2) grid.addwidget(list2) win.setlayout(grid) win.setgeometry(300, 150, 350, 300) win.setwindowtitle("example") win.show() sys.exit(app.exec_()) if __name__ == '__main__': window()
thanks assistance can provide.
the first parameter of rowstretch
method row number, second stretch factor. need 2 calls rowstretch
, this:
import sys pyqt4.qtcore import * pyqt4.qtgui import * def window(): app = qapplication(sys.argv) win = qwidget() list1 = qlistview() list2 = qlistview() grid = qgridlayout() grid.setrowstretch(0, 6) grid.setrowstretch(1, 4) grid.addwidget(list1) grid.setspacing(2) grid.addwidget(list2) win.setlayout(grid) win.setgeometry(300, 150, 350, 300) win.setwindowtitle("example") win.show() sys.exit(app.exec_()) if __name__ == '__main__': window()
Comments
Post a Comment