QVBoxLayout organizes your widgets vertically in a window.

Instead of organizing all the widgets yourself (specifying the geographic location), you can let PyQt take care of it.

Every new widget you add with .addWidget(), is added vertically. Basically you get a vertical list of your widgets. Each new widget is added to the bottom of the list.

Import QVBoxLayout from PyQt5.QtWidgets.

Download Examples:
Download PyQt examples

Vertical layout

QVboxLayout example

The simple example below creates a QVboxLayout. Then uses the method addWidget, which adds the newly created buttons in vertical direction.

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()

This creates this app:

pyqt vertical layout

The parameter in addWidget() accepts any widget in PyQt5.QtWidgets like QPushButton and all the other available widgets.

Don’t forget to add the QVBoxLayout to the window with window.setLayout(layout).