summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-08-11 21:22:57 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-09-05 13:43:44 +0000
commit5a96d13bb5abd5339cf21dd1de7a17152c71f0fc (patch)
tree03a4f9423a53b46168f26f3fc80ae6651d8c9ae4 /src
parent4367abb75a8ce07344006efd17317d5ad8e03f5f (diff)
QCheckBox: add new checkStateChanged(Qt::CheckState) signal
... to replace the old stateChanged(int) one, which a) had the wrong name and b) the wrong argument type. Mark the old one as \obsolete, so new users don't see it anymore. Prepare for deprecation in the test, but don't actually deprecate, yet (this author does not know how to deprecate signals). Found in API-review. Amends 37b47ebf946ef1a37573107375fbe5fc0eb1e6d2. As a drive-by, replace explicit qWait() calls with QTRY_COMPARE(). [ChangeLog][QtWidgets][QCheckBox] Added new checkStateChanged(Qt::CheckState) signal, obsoleting stateChanged(int). Fixes: QTBUG-104688 Change-Id: I01791fd003b752c47d99bea65151202be9175c21 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qcheckbox.cpp16
-rw-r--r--src/widgets/widgets/qcheckbox.h5
2 files changed, 14 insertions, 7 deletions
diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index 5b44271d48..cebb0b0b41 100644
--- a/src/widgets/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
@@ -59,7 +59,7 @@ public:
\endtable
Whenever a checkbox is checked or cleared, it emits the signal
- stateChanged(). Connect to this signal if you want to trigger an action
+ checkStateChanged(). Connect to this signal if you want to trigger an action
each time the checkbox changes state. You can use isChecked() to query
whether or not a checkbox is checked.
@@ -84,14 +84,22 @@ public:
setPixmap(), accel(), setAccel(), isToggleButton(), setDown(), isDown(),
isOn(), checkState(), autoRepeat(), isExclusiveToggle(), group(),
setAutoRepeat(), toggle(), pressed(), released(), clicked(), toggled(),
- checkState(), and stateChanged().
+ checkState(), and checkStateChanged().
\sa QAbstractButton, QRadioButton
*/
/*!
\fn void QCheckBox::stateChanged(int state)
- //! Qt 7: \fn void QCheckBox::stateChanged(Qt::CheckState state)
+
+ \obsolete
+
+ Use checkStateChanged(Qt::CheckState) instead.
+*/
+
+/*!
+ \fn void QCheckBox::checkStateChanged(Qt::CheckState state)
+ \since 6.7
This signal is emitted whenever the checkbox's state changes, i.e.,
whenever the user checks or unchecks it.
@@ -227,6 +235,7 @@ void QCheckBox::setCheckState(Qt::CheckState state)
d->refresh();
if (state != d->publishedState) {
d->publishedState = state;
+ emit checkStateChanged(state);
emit stateChanged(state);
}
@@ -322,6 +331,7 @@ void QCheckBox::checkStateSet()
Qt::CheckState state = checkState();
if (state != d->publishedState) {
d->publishedState = state;
+ emit checkStateChanged(state);
emit stateChanged(state);
}
}
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index e385dadbb8..54c2c3c796 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -36,11 +36,8 @@ public:
void setCheckState(Qt::CheckState state);
Q_SIGNALS:
-#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
void stateChanged(int);
-#else
- void stateChanged(Qt::CheckState);
-#endif
+ void checkStateChanged(Qt::CheckState);
protected:
bool event(QEvent *e) override;