QButtonGroup(3qt)
β¨ NAME β¨
QButtonGroup β organizes QButton widgets in a group π
π SYNOPSIS π
#include <qbuttongroup.h>
So bestie, here's the tea: this widget inherits QGroupBox, and it gets inherited by QHButtonGroup and QVButtonGroup. It's giving founding mother of button groups, honestly. π
πΈ Public Members πΈ
QButtonGroup ( QWidget * parent = 0, const char * name = 0 )QButtonGroup ( const QString & title, QWidget * parent = 0, const char * name = 0 )QButtonGroup ( int strips, Orientation orientation, QWidget * parent = 0, const char * name = 0 )QButtonGroup ( int strips, Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )bool isExclusive () constbool isRadioButtonExclusive () constvirtual void setExclusive ( bool )virtual void setRadioButtonExclusive ( bool )int insert ( QButton * button, int id = -1 )void remove ( QButton * button )QButton * find ( int id ) constint id ( QButton * button ) constint count () constvirtual void setButton ( int id )virtual void moveFocus ( int key )QButton * selected () constint selectedId () const
π£ Signals π£
void pressed ( int id )void released ( int id )void clicked ( int id )
π Properties π
bool exclusiveβ whether the button group is exclusivebool radioButtonExclusiveβ whether the radio buttons in the group are exclusiveint selectedIdβ the selected toggle button
π¦ DESCRIPTION π¦
The QButtonGroup widget organizes QButton widgets in a group. That's the whole job, and it does it so well.
A button group widget makes it easier to deal with groups of buttons. Every single button in a button group has its own unique identifier β like a lil name tag at a party π·οΈ. The button group emits a clicked() signal with this identifier when a button in the group is clicked. Which means this is highkey perfect when you've got a bunch of similar buttons and you want to connect all their clicked() signals to a single slot instead of doing it seventeen separate times. Efficiency queen. β¨
An exclusive button group switches off all toggle buttons except the one that was clicked. A button group is, by default, non-exclusive. But here's the important bit, no cap: note that all radio buttons that are inserted into a button group are mutually exclusive even if the button group is non-exclusive. (See setRadioButtonExclusive().)
There are two ways of using a button group:
- The button group is the parent widget of a number of buttons, i.e. the button group is the parent argument in the button constructor. The buttons are assigned identifiers
0,1,2, etc., in the order they are created. AQButtonGroupcan display a frame and a title because it inheritsQGroupBox. - The button group is an invisible widget and the contained buttons have some other parent widget. In this usage, each button must be manually inserted, using
insert(), into the button group and given an identifier.
A button can be removed from the group with remove(). A pointer to a button with a given id can be obtained using find(). The id of a button is available using id(). A button can be set on with setButton(). The number of buttons in the group is returned by count().
[Image Omitted]
[Image Omitted]
(yes bestie, the original page literally just has two images here and nothing else, so we're keeping the receipts π«Ά)
See also QPushButton, QCheckBox, QRadioButton, Widget Appearance and Style, Layout Management, and Organizers.
π MEMBER FUNCTION DOCUMENTATION π
QButtonGroup::QButtonGroup ( QWidget * parent = 0, const char * name = 0 )
Constructs a button group with no title.
The parent and name arguments are passed to the QWidget constructor.
QButtonGroup::QButtonGroup ( const QString & title, QWidget * parent = 0, const char * name = 0 )
Constructs a button group with the title title.
The parent and name arguments are passed to the QWidget constructor.
QButtonGroup::QButtonGroup ( int strips, Orientation orientation, QWidget * parent = 0, const char * name = 0 )
Constructs a button group with no title. Child widgets will be arranged in strips rows or columns (depending on orientation).
The parent and name arguments are passed to the QWidget constructor.
QButtonGroup::QButtonGroup ( int strips, Orientation orientation, const QString & title, QWidget * parent = 0, const char * name = 0 )
Constructs a button group with title title. Child widgets will be arranged in strips rows or columns (depending on orientation).
The parent and name arguments are passed to the QWidget constructor.
void QButtonGroup::clicked ( int id ) [signal]
This signal is emitted when a button in the group is clicked. The id argument is the button's identifier.
See also insert().
Examples:
Okay so the original literally just says "Examples:" and then points off into demo-land β we're keeping it exactly like that, no embellishment, that's the rule. π
int QButtonGroup::count () const
Returns the number of buttons in the group. Counting is a whole vibe, bestie. π’
QButton * QButtonGroup::find ( int id ) const
Returns the button with the specified identifier id, or 0 if the button was not found.
int QButtonGroup::id ( QButton * button ) const
Returns the id of button, or -1 if button is not a member of this group.
See also selectedId.
int QButtonGroup::insert ( QButton * button, int id = -1 )
Inserts the button with the identifier id 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 identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is equal to the number of buttons in the group. If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated. No button has an id of -1. Remember that, it's important. π¨
See also find(), remove(), and exclusive.
Examples:
Same situation as the clicked() signal above β the page says "Examples:" and that's it. Keeping it fr fr. π
bool QButtonGroup::isExclusive () const
Returns TRUE if the button group is exclusive; otherwise returns FALSE. See the "exclusive" property for details.
bool QButtonGroup::isRadioButtonExclusive () const
Returns TRUE if the radio buttons in the group are exclusive; otherwise returns FALSE. See the "radioButtonExclusive" property for details.
void QButtonGroup::moveFocus ( int key ) [virtual]
Moves the keyboard focus according to key, and if appropriate checks the new focus item.
This function does nothing unless the keyboard focus points to one of the button group members and key is one of Key_Up, Key_Down, Key_Left and Key_Right. Otherwise it's just sitting there, unbothered, moisturized, in its lane. π§
void QButtonGroup::pressed ( int id ) [signal]
This signal is emitted when a button in the group is pressed. The id argument is the button's identifier.
See also insert().
void QButtonGroup::released ( int id ) [signal]
This signal is emitted when a button in the group is released. The id argument is the button's identifier.
See also insert().
void QButtonGroup::remove ( QButton * button )
Removes the button from the button group. Bye bestie π
See also insert().
QButton * QButtonGroup::selected () const
Returns the selected toggle button if exactly one is selected; otherwise returns 0.
See also selectedId.
int QButtonGroup::selectedId () const
Returns the selected toggle button. See the "selectedId" property for details.
void QButtonGroup::setButton ( int id ) [virtual]
Sets the selected toggle button to id. See the "selectedId" property for details.
void QButtonGroup::setExclusive ( bool ) [virtual]
Sets whether the button group is exclusive. See the "exclusive" property for details.
void QButtonGroup::setRadioButtonExclusive ( bool ) [virtual]
Sets whether the radio buttons in the group are exclusive. See the "radioButtonExclusive" property for details.
π Property Documentation π
bool exclusive
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.
Set this property's value with setExclusive() and get this property's value with isExclusive().
bool radioButtonExclusive
This property holds whether the radio buttons in the group are exclusive.
If this property is TRUE (the default), the radiobuttons in the group are treated exclusively.
Set this property's value with setRadioButtonExclusive() and get this property's value with isRadioButtonExclusive().
int selectedId
This property holds the selected toggle button.
The toggle button is specified as an ID.
If no toggle button is selected, this property holds -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.
See also selected().
Set this property's value with setButton() and get this property's value with selectedId().
π SEE ALSO π
Β©οΈ COPYRIGHT Β©οΈ
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
βοΈ AUTHOR βοΈ
Generated automatically from the source code. (yes, it really says that β the machine wrote it, not a person, and honestly? iconic.)
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. π«Ά
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qbuttongroup.3qt) and the Qt version (3.3.8). Do that or the report is lowkey useless, bestie, we need the deets. π
aaaand that's the whole page!! this one came from Trolltech AS, dated 2 February 2007, and it's the QButtonGroup(3qt) man page in all its glory. go forth and group your buttons, you absolute main character πβ¨π
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms