Table of Contents
- QButtonGroup
- Synopsis
- Detailed Description
PySide2.QtWidgets.QButtonGroup
PySide2.QtWidgets.QButtonGroup.addButton()
PySide2.QtWidgets.QButtonGroup.button()
PySide2.QtWidgets.QButtonGroup.buttonClicked()
PySide2.QtWidgets.QButtonGroup.buttonPressed()
PySide2.QtWidgets.QButtonGroup.buttonReleased()
PySide2.QtWidgets.QButtonGroup.buttonToggled()
PySide2.QtWidgets.QButtonGroup.buttons()
PySide2.QtWidgets.QButtonGroup.checkedButton()
PySide2.QtWidgets.QButtonGroup.checkedId()
PySide2.QtWidgets.QButtonGroup.exclusive()
PySide2.QtWidgets.QButtonGroup.id()
PySide2.QtWidgets.QButtonGroup.idClicked()
PySide2.QtWidgets.QButtonGroup.idPressed()
PySide2.QtWidgets.QButtonGroup.idReleased()
PySide2.QtWidgets.QButtonGroup.idToggled()
PySide2.QtWidgets.QButtonGroup.removeButton()
PySide2.QtWidgets.QButtonGroup.setExclusive()
PySide2.QtWidgets.QButtonGroup.setId()
Previous topic
Next topic
Quick search
QButtonGroup¶
The
QButtonGroup
class provides a container to organize groups of button widgets. More…
Synopsis¶
Functions¶
def
addButton
(arg__1[, id=-1])def
button
(id)def
buttons
()def
checkedButton
()def
checkedId
()def
exclusive
()def
id
(button)def
removeButton
(arg__1)def
setExclusive
(arg__1)def
setId
(button, id)
Signals¶
def
buttonClicked
(arg__1)def
buttonClicked
(arg__1)def
buttonPressed
(arg__1)def
buttonPressed
(arg__1)def
buttonReleased
(arg__1)def
buttonReleased
(arg__1)def
buttonToggled
(arg__1, arg__2)def
buttonToggled
(arg__1, arg__2)def
idClicked
(arg__1)def
idPressed
(arg__1)def
idReleased
(arg__1)def
idToggled
(arg__1, arg__2)
Detailed Description¶
QButtonGroup
provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (seeQGroupBox
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 checkableQPushButton
s,QCheckBox
es (normally for non-exclusive button groups), orQRadioButton
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 withremoveButton()
. If the group is exclusive, the currently checked button is available withcheckedButton()
. If a button is clicked, thebuttonClicked()
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 bybuttons()
.In addition,
QButtonGroup
can map between integers and buttons. You can assign an integer id to a button withsetId()
, and retrieve it withid()
. The id of the currently checked button is available withcheckedId()
, and there is an overloaded signalbuttonClicked()
which emits the id of the button. The id-1
is reserved byQButtonGroup
to mean “no such button”. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.See also
- class PySide2.QtWidgets.QButtonGroup([parent=None])¶
- param parent:
Constructs a new, empty button group with the given
parent
.See also
- PySide2.QtWidgets.QButtonGroup.addButton(arg__1[, id=-1])¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
id – int
Adds the given
button
to the button group. Ifid
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.See also
- PySide2.QtWidgets.QButtonGroup.button(id)¶
- Parameters:
id – int
- Return type:
Returns the button with the specified
id
, orNone
if no such button exists.
- PySide2.QtWidgets.QButtonGroup.buttonClicked(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
- PySide2.QtWidgets.QButtonGroup.buttonClicked(arg__1)
- Parameters:
arg__1 – int
Note
This function is deprecated.
- PySide2.QtWidgets.QButtonGroup.buttonPressed(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
- PySide2.QtWidgets.QButtonGroup.buttonPressed(arg__1)
- Parameters:
arg__1 – int
Note
This function is deprecated.
- PySide2.QtWidgets.QButtonGroup.buttonReleased(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
- PySide2.QtWidgets.QButtonGroup.buttonReleased(arg__1)
- Parameters:
arg__1 – int
Note
This function is deprecated.
- PySide2.QtWidgets.QButtonGroup.buttonToggled(arg__1, arg__2)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
arg__2 – bool
- PySide2.QtWidgets.QButtonGroup.buttonToggled(arg__1, arg__2)
- Parameters:
arg__1 – int
arg__2 – bool
Note
This function is deprecated.
- PySide2.QtWidgets.QButtonGroup.buttons()¶
- Return type:
Returns the button group’s list of buttons. This may be empty.
See also
- PySide2.QtWidgets.QButtonGroup.checkedButton()¶
- Return type:
Returns the button group’s checked button, or
None
if no buttons are checked.See also
- PySide2.QtWidgets.QButtonGroup.checkedId()¶
- Return type:
int
Returns the id of the
checkedButton()
, or -1 if no button is checked.See also
- PySide2.QtWidgets.QButtonGroup.exclusive()¶
- Return type:
bool
This property holds whether the button group is exclusive.
If this property is
true
, then only one button in the group can be checked at any given time. The user can click on any button to check it, and that button will replace the existing one as the checked button in the group.In an exclusive group, the user cannot uncheck the currently checked button by clicking on it; instead, another button in the group must be clicked to set the new checked button for that group.
By default, this property is
true
.
- PySide2.QtWidgets.QButtonGroup.id(button)¶
- Parameters:
button –
PySide2.QtWidgets.QAbstractButton
- Return type:
int
Returns the id for the specified
button
, or -1 if no such button exists.See also
- PySide2.QtWidgets.QButtonGroup.idClicked(arg__1)¶
- Parameters:
arg__1 – int
- PySide2.QtWidgets.QButtonGroup.idPressed(arg__1)¶
- Parameters:
arg__1 – int
- PySide2.QtWidgets.QButtonGroup.idReleased(arg__1)¶
- Parameters:
arg__1 – int
- PySide2.QtWidgets.QButtonGroup.idToggled(arg__1, arg__2)¶
- Parameters:
arg__1 – int
arg__2 – bool
- PySide2.QtWidgets.QButtonGroup.removeButton(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QAbstractButton
Removes the given
button
from the button group.See also
- PySide2.QtWidgets.QButtonGroup.setExclusive(arg__1)¶
- Parameters:
arg__1 – bool
This property holds whether the button group is exclusive.
If this property is
true
, then only one button in the group can be checked at any given time. The user can click on any button to check it, and that button will replace the existing one as the checked button in the group.In an exclusive group, the user cannot uncheck the currently checked button by clicking on it; instead, another button in the group must be clicked to set the new checked button for that group.
By default, this property is
true
.
- PySide2.QtWidgets.QButtonGroup.setId(button, id)¶
- Parameters:
button –
PySide2.QtWidgets.QAbstractButton
id – int
Sets the
id
for the specifiedbutton
. Note thatid
cannot be -1.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.