PySide6.QtWidgets.QButtonGroup¶
- class QButtonGroup¶
- The - QButtonGroupclass provides a container to organize groups of button widgets. More…- Synopsis¶- Properties¶- exclusiveᅟ- Whether the button group is exclusive
 - Methods¶- def - __init__()
- def - addButton()
- def - button()
- def - buttons()
- def - checkedButton()
- def - checkedId()
- def - exclusive()
- def - id()
- def - removeButton()
- def - setExclusive()
- def - setId()
 - Signals¶- def - buttonClicked()
- def - buttonPressed()
- def - buttonReleased()
- def - buttonToggled()
- def - idClicked()
- def - idPressed()
- def - idReleased()
- def - idToggled()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- QButtonGroupprovides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see- QGroupBoxfor a container widget), but instead manages the states of each of the buttons in the group.- An - exclusivebutton 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- QPushButtons,- QCheckBoxes (normally for non-exclusive button groups), or- QRadioButtons. 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, - QButtonGroupcan 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 a signal- idClicked()that emits the id of the button. The id- -1is reserved by- QButtonGroupto mean “no such button”. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.- See also - Note - Properties can be used directly when - from __feature__ import true_propertyis used or via accessor functions otherwise.- property exclusiveᅟ: 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.- Access functions:
 - Constructs a new, empty button group with the given - parent.- See also - addButton(button[, id=-1])¶
- Parameters:
- button – - QAbstractButton
- id – int 
 
 
 - Adds the given - buttonto the button group. If- idis -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 - button(id)¶
- Parameters:
- id – int 
- Return type:
 
 - Returns the button with the specified - id, or- Noneif no such button exists.- buttonClicked(button)¶
- Parameters:
- button – - QAbstractButton
 
 - This signal is emitted when the given - buttonis clicked. A button is clicked when it is first pressed and then released, when its shortcut key is typed, or when- click()or- animateClick()is programmatically called.- See also - buttonPressed(button)¶
- Parameters:
- button – - QAbstractButton
 
 - This signal is emitted when the given - buttonis pressed down.- See also - buttonReleased(button)¶
- Parameters:
- button – - QAbstractButton
 
 - This signal is emitted when the given - buttonis released.- See also - buttonToggled(button, checked)¶
- Parameters:
- button – - QAbstractButton
- checked – bool 
 
 
 - This signal is emitted when the given - buttonis toggled.- checkedis true if the button is checked, or false if the button is unchecked.- See also - buttons()¶
- Return type:
- .list of QAbstractButton 
 
 - Returns the button group’s list of buttons. This may be empty. - See also - checkedButton()¶
- Return type:
 
 - Returns the button group’s checked button, or - Noneif no buttons are checked.- See also - checkedId()¶
- Return type:
- int 
 
 - Returns the id of the - checkedButton(), or -1 if no button is checked.- See also - exclusive()¶
- Return type:
- bool 
 - See also 
 - Getter of property - exclusiveᅟ.- id(button)¶
- Parameters:
- button – - QAbstractButton
- Return type:
- int 
 
 - Returns the id for the specified - button, or -1 if no such button exists.- See also - idClicked(id)¶
- Parameters:
- id – int 
 
 - This signal is emitted when a button with the given - idis clicked.- See also - idPressed(id)¶
- Parameters:
- id – int 
 
 - This signal is emitted when a button with the given - idis pressed down.- See also - idReleased(id)¶
- Parameters:
- id – int 
 
 - This signal is emitted when a button with the given - idis released.- See also - idToggled(id, checked)¶
- Parameters:
- id – int 
- checked – bool 
 
 
 - This signal is emitted when a button with the given - idis toggled.- checkedis true if the button is checked, or false if the button is unchecked.- See also - removeButton(button)¶
- Parameters:
- button – - QAbstractButton
 
 - Removes the given - buttonfrom the button group.- See also - setExclusive(arg__1)¶
- Parameters:
- arg__1 – bool 
 - See also 
 - Setter of property - exclusiveᅟ.- setId(button, id)¶
- Parameters:
- button – - QAbstractButton
- id – int 
 
 
 - Sets the - idfor the specified- button. Note that- idcannot be -1.- See also