Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting layout margins in pyqt

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

like image 280
waspinator Avatar asked May 17 '13 16:05

waspinator


People also ask

What is layout in PyQt?

In PyQt, layout managers are classes that provide the required functionality to automatically manage the size, position, and resizing behavior of the widgets in the layout. With layout managers, you can automatically arrange child widgets within any parent, or container, widget.

How do I use QHBoxLayout?

First, we create the widgets we want in the layout. Then, we create the QHBoxLayout object and add the widgets into the layout. Finally, we call setLayout() to install the QHBoxLayout object onto the widget. At that point, the widgets in the layout are reparented to have window as their parent.

What is widget in PyQt5?

PyQt5 Tutorial — Getting started with PyQt5 In Qt (and most User Interfaces) 'widget' is the name given to a component of the UI that the user can interact with. User interfaces are made up of multiple widgets, arranged within the window.


1 Answers

You can use QLayout.setContentsMargins:

# layout is a defined VBox or HBox
layout.setContentsMargins(left, top, right, bottom)
like image 151
waspinator Avatar answered Oct 12 '22 13:10

waspinator