summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorThorbjørn Martsum <tmartsum@gmail.com>2013-08-26 08:57:21 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-28 12:15:43 +0200
commitfd871694e74debc1bde5a7a19c6a5b94f3069bb2 (patch)
treed5430d2c50432adea3629cae7ca61df967351461 /src/widgets
parentea94afca565eb2e9586134c9921af23d1e478bb9 (diff)
QButtonGroup - add buttonToggled signals
QButtonGroup emits signals on clicked, pressed and released for buttons in the group, but for some (insuffienct) reason it did not emit anything for toggle (the only signal that it didn't emit anything for). This patch changes that, by adding handling of that signal to QButtonGroup. Task-number: QTBUG-14857 Change-Id: I88bcd7b060b78c7ff05ea1adf7baaddfe6d463be Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp16
-rw-r--r--src/widgets/widgets/qabstractbutton_p.h1
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp21
-rw-r--r--src/widgets/widgets/qbuttongroup.h3
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)