Setting layout margins in pyqt

waspinator picture waspinator · May 17, 2013 · Viewed 15.5k times · Source

In Qt Designer I can set the margin of a VBox or HBox using the properties layout*Margin.

How can I do that in pyqt?

enter image description here

Answer

waspinator picture waspinator · May 17, 2013

You can use QLayout.setContentsMargins:

# layout is a defined VBox or HBox
layout.setContentsMargins(left, top, right, bottom)