QButtonGroup

The QButtonGroup class provides a container to organize groups of button widgets. More

Inheritance diagram of PySide2.QtWidgets.QButtonGroup

Synopsis

Functions

Signals

Detailed Description

QButtonGroup provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see QGroupBox for a container widget), but instead manages the states of each of the buttons in the group.

An exclusive button group switches off all checkable (toggle) buttons except the one that has been clicked. By default, a button group is exclusive. The buttons in a button group are usually checkable QPushButton s, QCheckBox es (normally for non-exclusive button groups), or QRadioButton s. If you create an exclusive button group, you should ensure that one of the buttons in the group is initially checked; otherwise, the group will initially be in a state where no buttons are checked.

A button can be added to the group with addButton() and removed with removeButton() . If the group is exclusive, the currently checked button is available with checkedButton() . If a button is clicked, the buttonClicked() signal is emitted; for a checkable button in an exclusive group this means that the button has been checked. The list of buttons in the group is returned by buttons() .

In addition, QButtonGroup can map between integers and buttons. You can assign an integer id to a button with setId() , and retrieve it with id() . The id of the currently checked button is available with checkedId() , and there is an overloaded signal buttonClicked() which emits the id of the button. The id -1 is reserved by QButtonGroup to mean “no such button”. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.

class QButtonGroup([parent=None])
param parent

QObject

Constructs a new, empty button group with the given parent .

PySide2.QtWidgets.QButtonGroup.addButton(arg__1[, id=-1])
Parameters

Adds the given button to the button group. If id is -1, an id will be assigned to the button. Automatically assigned ids are guaranteed to be negative, starting with -2. If you are assigning your own ids, use positive values to avoid conflicts.

PySide2.QtWidgets.QButtonGroup.button(id)
Parameters

idint

Return type

QAbstractButton

Returns the button with the specified id , or 0 if no such button exists.

PySide2.QtWidgets.QButtonGroup.buttonClicked(arg__1)
Parameters

arg__1QAbstractButton

PySide2.QtWidgets.QButtonGroup.buttonClicked(arg__1)
Parameters

arg__1int

PySide2.QtWidgets.QButtonGroup.buttonPressed(arg__1)
Parameters

arg__1QAbstractButton

PySide2.QtWidgets.QButtonGroup.buttonPressed(arg__1)
Parameters

arg__1int

PySide2.QtWidgets.QButtonGroup.buttonReleased(arg__1)
Parameters

arg__1QAbstractButton

PySide2.QtWidgets.QButtonGroup.buttonReleased(arg__1)
Parameters

arg__1int

PySide2.QtWidgets.QButtonGroup.buttonToggled(arg__1, arg__2)
Parameters
PySide2.QtWidgets.QButtonGroup.buttonToggled(arg__1, arg__2)
Parameters
  • arg__1int

  • arg__2bool

PySide2.QtWidgets.QButtonGroup.buttons()
Return type

Returns the button group’s list of buttons. This may be empty.

PySide2.QtWidgets.QButtonGroup.checkedButton()
Return type

QAbstractButton

Returns the button group’s checked button, or 0 if no buttons are checked.

See also

buttonClicked()

PySide2.QtWidgets.QButtonGroup.checkedId()
Return type

int

Returns the id of the checkedButton() , or -1 if no button is checked.

See also

setId()

PySide2.QtWidgets.QButtonGroup.exclusive()
Return type

bool

See also

setExclusive()

PySide2.QtWidgets.QButtonGroup.id(button)
Parameters

buttonQAbstractButton

Return type

int

Returns the id for the specified button , or -1 if no such button exists.

See also

setId()

PySide2.QtWidgets.QButtonGroup.removeButton(arg__1)
Parameters

arg__1QAbstractButton

Removes the given button from the button group.

PySide2.QtWidgets.QButtonGroup.setExclusive(arg__1)
Parameters

arg__1bool

See also

exclusive()

PySide2.QtWidgets.QButtonGroup.setId(button, id)
Parameters

Sets the id for the specified button . Note that id cannot be -1.

See also

id()