11

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

Chris Chambers
  • 1,367
  • 21
  • 39
waspinator
  • 6,464
  • 11
  • 52
  • 78

1 Answers1

27

You can use QLayout.setContentsMargins:

# layout is a defined VBox or HBox
layout.setContentsMargins(left, top, right, bottom)
Božo Stojković
  • 2,893
  • 1
  • 27
  • 52
waspinator
  • 6,464
  • 11
  • 52
  • 78
  • Doesn't work for me on PyQt5. Method is the same, but whatever margin size I set has no effect at all. – Karolis Mar 16 '23 at 08:23