#include <qbuttongroup.h>
Inheritance diagram for QButtonGroup:


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 purpose of the mapping mechanism is to simplify the representation of enum values in a user interface.
Definition at line 39 of file qbuttongroup.h.
Signals | |
| void | buttonClicked (QAbstractButton *) |
| void | buttonClicked (int) |
| void | buttonPressed (QAbstractButton *) |
| void | buttonPressed (int) |
| void | buttonReleased (QAbstractButton *) |
| void | buttonReleased (int) |
Public Member Functions | |
| QButtonGroup (QObject *parent=0) | |
| ~QButtonGroup () | |
| void | setExclusive (bool) |
| bool | exclusive () const |
| void | addButton (QAbstractButton *) |
| void | addButton (QAbstractButton *, int id) |
| void | removeButton (QAbstractButton *) |
| QList< QAbstractButton * > | buttons () const |
| QAbstractButton * | checkedButton () const |
| QAbstractButton * | button (int id) const |
| void | setId (QAbstractButton *button, int id) |
| int | id (QAbstractButton *button) const |
| int | checkedId () const |
Friends | |
| class | QAbstractButton |
| class | QAbstractButtonPrivate |
| QButtonGroup::QButtonGroup | ( | QObject * | parent = 0 |
) | [explicit] |
Constructs a new, empty button group with the given parent.
Definition at line 175 of file qabstractbutton.cpp.
00176 : QObject(*new QButtonGroupPrivate, parent) 00177 { 00178 }
| QButtonGroup::~QButtonGroup | ( | ) |
| void QButtonGroup::setExclusive | ( | bool | ) |
Definition at line 194 of file qabstractbutton.cpp.
References d.
Referenced by Q3ButtonGroup::init(), and Q3ButtonGroup::setExclusive().
00195 { 00196 Q_D(QButtonGroup); 00197 d->exclusive = exclusive; 00198 }
| bool QButtonGroup::exclusive | ( | ) | const |
Definition at line 188 of file qabstractbutton.cpp.
References d.
Referenced by QAbstractButtonPrivate::click(), Q3ButtonGroup::event(), Q3ButtonGroup::isExclusive(), QAbstractButtonPrivate::moveFocus(), and QAbstractButtonPrivate::notifyChecked().
00189 { 00190 Q_D(const QButtonGroup); 00191 return d->exclusive; 00192 }
| void QButtonGroup::addButton | ( | QAbstractButton * | button | ) |
Adds the given button to the end of the group's internal list of buttons.
Definition at line 205 of file qabstractbutton.cpp.
References button().
Referenced by Q3ButtonGroup::insert_helper().
Here is the call graph for this function:

| void QButtonGroup::addButton | ( | QAbstractButton * | button, | |
| int | id = -1 | |||
| ) |
Adds the given button to the button group, with the given id.
Definition at line 210 of file qabstractbutton.cpp.
References button(), d, QAbstractButton::group(), and QAbstractButton::isChecked().
00211 { 00212 Q_D(QButtonGroup); 00213 if (QButtonGroup *previous = button->d_func()->group) 00214 previous->removeButton(button); 00215 button->d_func()->group = this; 00216 d->buttonList.append(button); 00217 if (id != -1) 00218 d->mapping[button] = id; 00219 if (d->exclusive && button->isChecked()) 00220 button->d_func()->notifyChecked(); 00221 }
Here is the call graph for this function:

| void QButtonGroup::removeButton | ( | QAbstractButton * | button | ) |
Removes the given button from the button group.
Definition at line 223 of file qabstractbutton.cpp.
References button(), d, and QAbstractButton::group().
Referenced by Q3ButtonGroup::remove().
00224 { 00225 Q_D(QButtonGroup); 00226 if (d->checkedButton == button) { 00227 d->detectCheckedButton(); 00228 } 00229 if (button->d_func()->group == this) { 00230 button->d_func()->group = 0; 00231 d->buttonList.removeAll(button); 00232 d->mapping.remove(button); 00233 } 00234 }
Here is the call graph for this function:

| QList< QAbstractButton * > QButtonGroup::buttons | ( | ) | const |
Returns the list of this groups's buttons. This may be empty.
Definition at line 236 of file qabstractbutton.cpp.
References d.
00237 { 00238 Q_D(const QButtonGroup); 00239 return d->buttonList; 00240 }
| QAbstractButton * QButtonGroup::checkedButton | ( | ) | const |
Returns the button group's checked button, or 0 if no buttons are checked.
Definition at line 242 of file qabstractbutton.cpp.
References d.
Referenced by QAbstractButtonPrivate::notifyChecked(), and QAbstractButtonPrivate::queryCheckedButton().
00243 { 00244 Q_D(const QButtonGroup); 00245 return d->checkedButton; 00246 }
| QAbstractButton * QButtonGroup::button | ( | int | id | ) | const |
Definition at line 248 of file qabstractbutton.cpp.
References d.
Referenced by addButton(), id(), removeButton(), and setId().
00249 { 00250 Q_D(const QButtonGroup); 00251 return d->mapping.key(id); 00252 }
| void QButtonGroup::setId | ( | QAbstractButton * | button, | |
| int | id | |||
| ) |
Definition at line 254 of file qabstractbutton.cpp.
00255 { 00256 Q_D(QButtonGroup); 00257 if (button && id != -1) 00258 d->mapping[button] = id; 00259 }
Here is the call graph for this function:

| int QButtonGroup::id | ( | QAbstractButton * | button | ) | const |
Definition at line 261 of file qabstractbutton.cpp.
Referenced by QAbstractButtonPrivate::emitClicked(), QAbstractButtonPrivate::emitPressed(), and QAbstractButtonPrivate::emitReleased().
00262 { 00263 Q_D(const QButtonGroup); 00264 return d->mapping.value(button, -1); 00265 }
Here is the call graph for this function:

| int QButtonGroup::checkedId | ( | ) | const |
Definition at line 267 of file qabstractbutton.cpp.
References d.
00268 { 00269 Q_D(const QButtonGroup); 00270 return d->mapping.value(d->checkedButton, -1); 00271 }
| void QButtonGroup::buttonClicked | ( | QAbstractButton * | button | ) | [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() or QAbstractButton::animateClick() is called.
Referenced by QAbstractButtonPrivate::emitClicked().
| void QButtonGroup::buttonClicked | ( | int | id | ) | [signal] |
This signal is emitted when a button with the given id is clicked.
| void QButtonGroup::buttonPressed | ( | QAbstractButton * | button | ) | [signal] |
Referenced by QAbstractButtonPrivate::emitPressed().
| void QButtonGroup::buttonPressed | ( | int | id | ) | [signal] |
| void QButtonGroup::buttonReleased | ( | QAbstractButton * | button | ) | [signal] |
Referenced by QAbstractButtonPrivate::emitReleased().
| void QButtonGroup::buttonReleased | ( | int | id | ) | [signal] |
friend class QAbstractButton [friend] |
Definition at line 82 of file qbuttongroup.h.
friend class QAbstractButtonPrivate [friend] |
Definition at line 83 of file qbuttongroup.h.
1.5.1