QRadioButton, QGroupBox, and QTabWidget

Understand how our GUI applications use QRadioButton, QGroupBox, and QTabWidget widgets.


You can create option buttons with the QRadioButton class that can be turned on when checked or off when unchecked. A round button and an associated label or icon make up each radio button. Radio buttons are typically employed when you need to give a user many options. Only one can be checked at once. The other radio buttons are unchecked as the user chooses another radio button. If one radio button is checked inside the parent, all the other buttons will become unchecked. When you set multiple radio buttons in a parent widget, those buttons become auto-exclusive, meaning they automatically become exclusive members of that group.

The setAutoExclusive() attribute can be set to "False" to alter this behavior. Additionally, utilize the QButtonGroup class to keep the various groups of radio buttons separate if you wish to add several exclusive groups of radio buttons to the same parent widget. Regarding signal emission, radio buttons are comparable to the QCheckBox class. When checked on or off, a radio button generates the toggled() signal, which can be attached to launch an action.


The QGroupBox widget offers a container for bundling devices with related functions. A group box has a top title and a border. The title may also be checkable, allowing the group box's child widgets to be enabled or disabled depending on whether the checkbox is selected or deselected. Any device may be contained within a group box object. QGroupBox does not automatically arrange its child widgets, so you must provide a layout like either QGridLayout or QHBoxLayout. The coding example that follows shows how to make a QGroupBox widget, include two radio buttons, and use a layout:

Get hands-on with 1200+ tech skills courses.