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.
Related Course: Create GUI Apps with Python PyQt5
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.
1 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout |
This creates this app:

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).