CopperSpice API  1.7.2
QButtonGroup Class Reference

The QButtonGroup class provides a container to organize groups of button widgets. More...

Inheritance diagram for QButtonGroup:
QObject

Public Signals

void buttonClicked (int id)
 
void buttonClicked (QAbstractButton *button)
 
void buttonPressed (int id)
 
void buttonPressed (QAbstractButton *button)
 
void buttonReleased (int id)
 
void buttonReleased (QAbstractButton *button)
 
void buttonToggled (int id, bool enabled)
 
void buttonToggled (QAbstractButton *button, bool enabled)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QButtonGroup (QObject *parent=nullptr)
 
 ~QButtonGroup ()
 
void addButton (QAbstractButton *button, int id=-1)
 
QAbstractButtonbutton (int id) const
 
QList< QAbstractButton * > buttons () const
 
QAbstractButtoncheckedButton () const
 
int checkedId () const
 
bool exclusive () const
 
int id (QAbstractButton *button) const
 
void removeButton (QAbstractButton *button)
 
void setExclusive (bool)
 
void setId (QAbstractButton *button, int id)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Properties

 exclusive
 
- Properties inherited from QObject
 objectName
 

Friends

class QAbstractButton
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

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, QCheckBoxes (normally for non-exclusive button groups), or QRadioButtons. 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.

See also
QGroupBox, QPushButton, QCheckBox, QRadioButton

Constructor & Destructor Documentation

QButtonGroup::QButtonGroup ( QObject parent = nullptr)
explicit

Constructs a new, empty button group with the given parent.

See also
addButton(), setExclusive()
QButtonGroup::~QButtonGroup ( )

Destroys the button group.

Method Documentation

void QButtonGroup::addButton ( QAbstractButton button,
int  id = -1 
)

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 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.

See also
removeButton(), buttons()

Adds the given button to the button group, with the given id. It is recommended to assign only positive ids.

See also
removeButton(), buttons()
QAbstractButton * QButtonGroup::button ( int  id) const

Returns the button with the specified id, or 0 if no such button exists.

void QButtonGroup::buttonClicked ( int  id)
signal

This signal is emitted when a button with the given id is clicked.

See also
checkedButton(), QAbstractButton::clicked()
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.

See also
checkedButton(), QAbstractButton::clicked()
void QButtonGroup::buttonPressed ( int  id)
signal

This signal is emitted when a button with the given id is pressed down.

See also
QAbstractButton::pressed()
void QButtonGroup::buttonPressed ( QAbstractButton button)
signal

This signal is emitted when the given button is pressed down.

See also
QAbstractButton::pressed()
void QButtonGroup::buttonReleased ( int  id)
signal

This signal is emitted when a button with the given id is released.

See also
QAbstractButton::released()
void QButtonGroup::buttonReleased ( QAbstractButton button)
signal

This signal is emitted when the given button is released.

See also
QAbstractButton::released()
QList< QAbstractButton * > QButtonGroup::buttons ( ) const

Returns the list of this group's buttons. This may be empty.

See also
addButton(), removeButton()
void QButtonGroup::buttonToggled ( int  id,
bool  enabled 
)
signal

Documentation pending.

void QButtonGroup::buttonToggled ( QAbstractButton button,
bool  enabled 
)
signal

Documentation pending.

QAbstractButton * QButtonGroup::checkedButton ( ) const

Returns the button group's checked button, or 0 if no buttons are checked.

See also
buttonClicked()
int QButtonGroup::checkedId ( ) const

Returns the id of the checkedButton(), or -1 if no button is checked.

See also
setId()
bool QButtonGroup::exclusive ( ) const

Property documentation pending.

int QButtonGroup::id ( QAbstractButton button) const

Returns the id for the specified button, or -1 if no such button exists.

See also
setId()
void QButtonGroup::removeButton ( QAbstractButton button)

Removes the given button from the button group.

See also
addButton(), buttons()
void QButtonGroup::setExclusive ( bool  )

Property documentation pending.

void QButtonGroup::setId ( QAbstractButton button,
int  id 
)

Sets the id for the specified button. Note that id can not be -1.

See also
id()

Property Documentation

QButtonGroup::exclusive

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 can not 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.

PropertiesClass Methods
read exclusive
write setExclusive