QLayout
QLayout
is the base class of all layout objects in PySide6.QtWidgets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent |
QWidget
|
The parent widget of the layout. |
None
|
Methods
Examples
yes_button = QtWidgets.QPushButton("press me")
no_button = QtWidgets.QPushButton("don't press me")
# QVBoxLayout is a subclass of QLayout
layout = QtWidgets.QVBoxLayout()
layout.addWidget(button)
layout.addWidget(no_button)
QVBoxLayout
layout.
We can use the addWidget
method because QVBoxLayout
is a subclass of QLayout
.
addWidget(w)
Adds the widget w
to the layout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
w |
QWidget
|
The widget to add to the layout. |
required |
setSpacing(space)
Sets the spacing between the items in the layout to space
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
space |
int
|
The spacing between the items in the layout. |
required |
spacing()
Gets the spacing between the items in the layout.
Returns:
Type | Description |
---|---|
int
|
The spacing between the items in the layout. |