The PySide.QtGui.QButtonGroup class provides a container to organize groups of button widgets.
PySide.QtGui.QButtonGroup provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see PySide.QtGui.QGroupBox for a container widget), but instead manages the states of each of the buttons in the group.
An PySide.QtGui.QButtonGroup.exclusive() button group switches off all checkable (toggle) buttons except the one that was clicked. By default, a button group is exclusive. The buttons in a button group are usually checkable PySide.QtGui.QPushButton ‘s, PySide.QtGui.QCheckBox es (normally for non-exclusive button groups), or PySide.QtGui.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 is added to the group with PySide.QtGui.QButtonGroup.addButton() . It can be removed from the group with PySide.QtGui.QButtonGroup.removeButton() . If the group is exclusive, the currently checked button is available as PySide.QtGui.QButtonGroup.checkedButton() . If a button is clicked the PySide.QtGui.QButtonGroup.buttonClicked() signal is emitted. For a checkable button in an exclusive group this means that the button was checked. The list of buttons in the group is returned by PySide.QtGui.QButtonGroup.buttons() .
In addition, PySide.QtGui.QButtonGroup can map between integers and buttons. You can assign an integer id to a button with PySide.QtGui.QButtonGroup.setId() , and retrieve it with PySide.QtGui.QButtonGroup.id() . The id of the currently checked button is available with PySide.QtGui.QButtonGroup.checkedId() , and there is an overloaded signal PySide.QtGui.QButtonGroup.buttonClicked() which emits the id of the button. The id -1 is reserved by PySide.QtGui.QButtonGroup to mean “no such button”. The purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.
Parameters: | parent – PySide.QtCore.QObject |
---|
Constructs a new, empty button group with the given parent .
Parameters: |
|
---|
Adds the given button to the button group, with the given id . It is recommended to assign only positive ids.
Parameters: | arg__1 – PySide.QtGui.QAbstractButton |
---|
Adds the given button to the end of the group’s internal list of buttons. An id will be assigned to the button by this PySide.QtGui.QButtonGroup . Automatically assigned ids are guaranteed to be negative, starting with -2. If you are also assigning your own ids, use positive values to avoid conflicts.
Parameters: | id – PySide.QtCore.int |
---|---|
Return type: | PySide.QtGui.QAbstractButton |
Returns the button with the specified id , or 0 if no such button exists.
Parameters: | arg__1 – PySide.QtCore.int |
---|
Parameters: | arg__1 – PySide.QtGui.QAbstractButton |
---|
Parameters: | arg__1 – PySide.QtGui.QAbstractButton |
---|
Parameters: | arg__1 – PySide.QtCore.int |
---|
Parameters: | arg__1 – PySide.QtCore.int |
---|
Parameters: | arg__1 – PySide.QtGui.QAbstractButton |
---|
Return type: |
---|
Returns the list of this groups’s buttons. This may be empty.
Return type: | PySide.QtGui.QAbstractButton |
---|
Returns the button group’s checked button, or 0 if no buttons are checked.
Return type: | PySide.QtCore.int |
---|
Returns the id of the PySide.QtGui.QButtonGroup.checkedButton() , or -1 if no button is checked.
See also
Return type: | PySide.QtCore.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.
Parameters: | button – PySide.QtGui.QAbstractButton |
---|---|
Return type: | PySide.QtCore.int |
Returns the id for the specified button , or -1 if no such button exists.
See also
Parameters: | arg__1 – PySide.QtGui.QAbstractButton |
---|
Removes the given button from the button group.
Parameters: | arg__1 – PySide.QtCore.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.
Parameters: |
|
---|
Sets the id for the specified button . Note that id can not be -1.
See also