Skip to content

QCheckBox


A QCheckBox widget is a toggle button that can be checked or unchecked. Checkboxes are typically used to represent features in an application that can be enabled or disabled without affecting others. By default, a checkbox is unchecked.

Parameters:

Name Type Description Default
text str

The text to display next to the checkbox.

None

Signals

  • stateChanged: Emitted whenever the checkbox's state changes.

Methods


Examples


checkbox = QtWidgets.QCheckBox()
print(checkbox.IsChecked())
False
checkbox.setChecked(True)
print(checkbox.IsChecked())
True


IsChecked()

Returns True if the checkbox is checked; otherwise returns False.

Returns:

Type Description
bool

True if the checkbox is checked; otherwise False.


setChecked(checked)

Sets the checkbox to be checked if checked is True; otherwise sets it to be unchecked.

Parameters:

Name Type Description Default
checked bool

True to check the checkbox; otherwise False.

required


setText(text)

Set the text to display next to the checkbox.

Parameters:

Name Type Description Default
text str

The text to display next to the checkbox.

required


text()

Get the text displayed next to the checkbox.

Returns:

Name Type Description
str str

The text displayed next to the checkbox.