
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3ButtonGroup widget organizesQAbstractButton widgets in a group.More...
| Header: | #include <Q3ButtonGroup> |
| Inherits: | Q3GroupBox |
| Inherited By: |
| Q3ButtonGroup(QWidget * parent = 0, const char * name = 0) | |
| Q3ButtonGroup(const QString & title, QWidget * parent = 0, const char * name = 0) | |
| Q3ButtonGroup(int strips, Qt::Orientation orientation, QWidget * parent = 0, const char * name = 0) | |
| Q3ButtonGroup(int strips, Qt::Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0) | |
| ~Q3ButtonGroup() | |
| int | count() const |
| QAbstractButton * | find(int id) const |
| int | id(QAbstractButton * button) const |
| int | insert(QAbstractButton * button, int id = -1) |
| bool | isExclusive() const |
| bool | isRadioButtonExclusive() const |
| void | remove(QAbstractButton * button) |
| QAbstractButton * | selected() const |
| int | selectedId() const |
| void | setButton(int id) |
| void | setExclusive(bool) |
| void | setRadioButtonExclusive(bool) |
| virtual bool | event(QEvent * e) |
TheQ3ButtonGroup widget organizesQAbstractButton widgets in a group.
A button group widget makes it easier to deal with groups of buttons. Each button in a button group has a unique identifier. The button group emits aclicked() signal with this identifier when a button in the group is clicked. This makes a button group particularly useful when you have several similar buttons and want to connect all theirclicked() signals to a single slot.
Anexclusive button group switches off all toggle buttons except the one that was clicked. A button group is, by default, non-exclusive. Note that all radio buttons that are inserted into a button group are mutually exclusive even if the button group is non-exclusive. (SeesetRadioButtonExclusive().)
There are two ways of using a button group:
A button can be removed from the group withremove(). A pointer to a button with a given id can be obtained usingfind(). The id of a button is available usingid(). A button can be seton withsetButton(). The number of buttons in the group is returned bycount().
See alsoQPushButton,QCheckBox, andQRadioButton.
This property holds whether the button group is exclusive.
If this property is true, then the buttons in the group are toggled, and to untoggle a button you must click on another button in the group. The default value is false.
Access functions:
| bool | isExclusive() const |
| void | setExclusive(bool) |
This property holds whether the radio buttons in the group are exclusive.
If this property is true (the default), theradio buttons in the group are treated exclusively.
Access functions:
| bool | isRadioButtonExclusive() const |
| void | setRadioButtonExclusive(bool) |
This property holds the id of the selected toggle button.
If no toggle button is selected,id() returns -1.
If setButton() is called on an exclusive group, the button with the given id will be set to on and all the others will be set to off.
Access functions:
| int | selectedId() const |
| void | setButton(int id) |
See alsoselected().
Constructs a button group with no title.
Theparent andname arguments are passed to theQWidget constructor.
Constructs a button group with the titletitle.
Theparent andname arguments are passed to theQWidget constructor.
Constructs a button group with no title. Child widgets will be arranged instrips rows or columns (depending onorientation).
Theparent andname arguments are passed to theQWidget constructor.
Constructs a button group with titletitle. Child widgets will be arranged instrips rows or columns (depending onorientation).
Theparent andname arguments are passed to theQWidget constructor.
Destructor.
[signal]void Q3ButtonGroup::clicked(int id)This signal is emitted when a button in the group isclicked. Theid argument is the button's identifier.
See alsoinsert().
Returns the number of buttons in the group.
[virtual protected]bool Q3ButtonGroup::event(QEvent * e)Reimplemented fromQObject::event().
Returns the button with the specified identifierid, or 0 if the button was not found.
Returns the id ofbutton, or -1 ifbutton is not a member of this group.
See alsoselectedId().
Inserts thebutton with the identifierid into the button group. Returns the button identifier.
Buttons are normally inserted into a button group automatically by passing the button group as the parent when the button is constructed. So it is not necessary to manually insert buttons that have this button group as their parent widget. An exception is when you want custom identifiers instead of the default 0, 1, 2, etc., or if you want the buttons to have some other parent.
The button is assigned the identifierid or an automatically generated identifier. It works as follows: Ifid >= 0, this identifier is assigned. Ifid == -1 (default), the identifier is equal to the number of buttons in the group. Ifid is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated. No button has an id of -1.
See alsofind(),remove(), andsetExclusive().
[signal]void Q3ButtonGroup::pressed(int id)This signal is emitted when a button in the group ispressed. Theid argument is the button's identifier.
See alsoinsert().
[signal]void Q3ButtonGroup::released(int id)This signal is emitted when a button in the group isreleased. Theid argument is the button's identifier.
See alsoinsert().
Removes thebutton from the button group.
See alsoinsert().
Returns the selected toggle button if exactly one is selected; otherwise returns 0.
See alsoselectedId().
© 2016 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 theGNU 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.