12

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

1 Answer 1

28

You can use QLayout.setContentsMargins:

# layout is a defined VBox or HBox
layout.setContentsMargins(left, top, right, bottom)
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't work for me on PyQt5. Method is the same, but whatever margin size I set has no effect at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.