diff options
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qabstractbutton.cpp | 16 | ||||
-rw-r--r-- | src/widgets/widgets/qabstractbutton_p.h | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qbuttongroup.cpp | 21 | ||||
-rw-r--r-- | src/widgets/widgets/qbuttongroup.h | 3 |
4 files changed, 39 insertions, 2 deletions
diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 3f9b28a883..be712f0747 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -575,6 +575,20 @@ void QAbstractButtonPrivate::emitReleased() #endif } +void QAbstractButtonPrivate::emitToggled(bool checked) +{ + Q_Q(QAbstractButton); + QPointer<QAbstractButton> guard(q); + emit q->toggled(checked); +#ifndef QT_NO_BUTTONGROUP + if (guard && group) { + emit group->buttonToggled(group->id(q), checked); + if (guard && group) + emit group->buttonToggled(q, checked); + } +#endif +} + /*! Constructs an abstract button with a \a parent. */ @@ -758,7 +772,7 @@ void QAbstractButton::setChecked(bool checked) if (guard && checked) d->notifyChecked(); if (guard) - emit toggled(checked); + d->emitToggled(checked); #ifndef QT_NO_ACCESSIBILITY diff --git a/src/widgets/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h index 4585728848..a148e60717 100644 --- a/src/widgets/widgets/qabstractbutton_p.h +++ b/src/widgets/widgets/qabstractbutton_p.h @@ -103,6 +103,7 @@ public: void emitPressed(); void emitReleased(); void emitClicked(); + void emitToggled(bool checked); }; QT_END_NAMESPACE diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index f22910007f..c484b154fd 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -174,6 +174,27 @@ */ /*! + \fn void QButtonGroup::buttonToggled(QAbstractButton *button, bool checked) + \since 5.2 + + This signal is emitted when the given \a button is toggled. + \a checked is true if the button is checked, or false if the button is unchecked. + + \sa QAbstractButton::toggled() +*/ + +/*! + \fn void QButtonGroup::buttonToggled(int id, bool checked) + \since 5.2 + + This signal is emitted when a button with the given \a id is toggled. + \a checked is true if the button is checked, or false if the button is unchecked. + + \sa QAbstractButton::toggled() +*/ + + +/*! \fn void QButtonGroup::addButton(QAbstractButton *button, int id = -1); Adds the given \a button to the button group. If \a id is -1, diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index 84fe26e0df..06656bf18c 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -85,7 +85,8 @@ Q_SIGNALS: void buttonPressed(int); void buttonReleased(QAbstractButton *); void buttonReleased(int); - + void buttonToggled(QAbstractButton *, bool); + void buttonToggled(int, bool); private: Q_DISABLE_COPY(QButtonGroup) |