The QButtonGroup class provides a container to organize groups of button widgets. 更多...
继承 QObject .
The QButtonGroup class provides a container to organize groups of button widgets.
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 was 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 is added to the group with addButton (). It can be removed from the group with removeButton (). If the group is exclusive, the currently checked button is available as checkedButton (). If a button is clicked the 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 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.
parent argument, if not None, causes self to be owned by Qt instead of PyQt.
Constructs a new, empty button group with the given parent .
另请参阅 addButton () 和 setExclusive ().
添加给定 button to the end of the group's internal list of buttons. An id will be assigned to the button by this 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.
另请参阅 removeButton () 和 buttons ().
添加给定 button to the button group, with the given id . It is recommended to assign only positive ids.
另请参阅 removeButton () 和 buttons ().
Returns the button with the specified id , or 0 if no such button exists.
该函数在 Qt 4.1 引入。
Returns the list of this groups's buttons. This may be empty.
另请参阅 addButton () 和 removeButton ().
Returns the button group's checked button, or 0 if no buttons are checked.
另请参阅 buttonClicked ().
Returns the id of the checkedButton (), or -1 if no button is checked.
该函数在 Qt 4.1 引入。
另请参阅 setId ().
Returns the id for the specified button , or -1 if no such button exists.
该函数在 Qt 4.1 引入。
另请参阅 setId ().
移除给定 button 从按钮组。
另请参阅 addButton () 和 buttons ().
设置 id 为指定 button 。注意 id can not be -1.
该函数在 Qt 4.1 引入。
另请参阅 id ().
This is the default overload of this signal.
This signal is emitted when the given button is clicked. A button is clicked when it is first pressed and then released, when its shortcut key is typed, or programmatically when QAbstractButton.click () 或 QAbstractButton.animateClick () 被调用。
另请参阅 checkedButton () 和 QAbstractButton.clicked ().
This signal is emitted when a button with the given id is clicked.
另请参阅 checkedButton () 和 QAbstractButton.clicked ().
This is the default overload of this signal.
This signal is emitted when the given button is pressed down.
该函数在 Qt 4.2 引入。
另请参阅 QAbstractButton.pressed ().
This signal is emitted when a button with the given id is pressed down.
该函数在 Qt 4.2 引入。
另请参阅 QAbstractButton.pressed ().
This is the default overload of this signal.
This signal is emitted when the given button is released.
该函数在 Qt 4.2 引入。
另请参阅 QAbstractButton.released ().
This signal is emitted when a button with the given id is released.
该函数在 Qt 4.2 引入。
另请参阅 QAbstractButton.released ().