The QCheckBox Widget
Learn about how we can make checkboxes with PyQt.
We'll cover the following
The QCheckBox
widget is a selectable button with typically two states, on or off. Checkboxes are ideal for displaying GUI elements that may be either enabled or disabled because they often have just two states, such as in a survey. Additionally, QCheckBox
can be used in more dynamic applications. For instance, when activated, the checkbox might be used to alter the window's title or even the label text. When the user interacts with a box, we perform a method that shows how to determine the widget's current state. The user is free to check all the checkboxes that pertain to them if they want to.
Note: You can pick more than one checkbox at once since checkboxes are not mutually exclusive. Add the checkboxes to a
QButtonGroup
object to make them mutually exclusive.
Using the QCheckbox widget
We start by importing the necessary modules from QtWidgets
(QApplication
, QWidget
, QCheckBox
, QLabel
) and QtCore
(Qt
) and sys
.
Get hands-on with 1200+ tech skills courses.