QGroupBox can group widgets, it provides a frame, title on top and it can display a multiple of widgets inside. It typically has a title and a border. Any PyQt widget can be added into the group box. This can be further used to communciate your UI/UX to your user.
This example demonstrates how to create the groupbox as shown below:
Related Course: Create GUI Apps with Python PyQt5
The groupbox is initialized with
QGroupBox("title"). Using the constructor is the normal way to set the title (you can also set the alignment: top, bottom, left, right, center). A layout is then added to the groupbox. Widgets are added to the layout.
A QGroupBox doesn’t layout the widgets automatically, so you have to do that yourself. You can use QVBoxLayout or QHBoxLayout for that.
A groupbox can be checkable. All of that said, that gives us the following initializiation:
groupbox = QGroupBox("GroupBox Example")
Individual widgets can then be added to the QVBoxLayout.
This example below creates a checkable groupbox, title and with several widgets add to it
from PyQt5.QtWidgets import *
If you are new to Python PyQt, then I highly recommend this book.