Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Add QSpacerItem to the very bottom
import sys
from PySide2.QtWidgets import QApplication, QMainWindow, QGridLayout, QPushButton, QWidget, QSpacerItem, QSizePolicy
class Main(QMainWindow):
def __init__(self):
super(Main, self).__init__()
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
# добавляем компоновщик-сетку
self.v_grid = QGridLayout(centralWidget)
# добавляем кнопки
for i in range(5):
self.v_grid.addWidget(QPushButton(f"Button {i}"))
# Добавляем QSpacer, политики размера нужны, так как по умолчанию они Fixed
self.v_grid.addItem(QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Main()
ex.show()
sys.exit(app.exec_())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question