QCheckBox: deprecate stateChanged()
[ChangeLog][QtWidgets][Deprecation Notices][QCheckBox]
stateChanged(int) has been deprecated in favor of
checkStateChanged(Qt:CheckState).
Found in API-review. Amends 5a96d13bb5.
Pick-to: 6.7
Change-Id: I6ff4aa38c2f43622ba4b127420aff83790785455
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
bb10
parent
6dfc988ea0
commit
3512fb1ec5
|
|
@ -92,9 +92,7 @@ public:
|
|||
/*!
|
||||
\fn void QCheckBox::stateChanged(int state)
|
||||
|
||||
\obsolete
|
||||
|
||||
Use checkStateChanged(Qt::CheckState) instead.
|
||||
\deprecated [6.9] Use checkStateChanged(Qt::CheckState) instead.
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -236,7 +234,11 @@ void QCheckBox::setCheckState(Qt::CheckState state)
|
|||
if (state != d->publishedState) {
|
||||
d->publishedState = state;
|
||||
emit checkStateChanged(state);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QT_IGNORE_DEPRECATIONS(
|
||||
emit stateChanged(state);
|
||||
)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if QT_CONFIG(accessibility)
|
||||
|
|
@ -332,7 +334,11 @@ void QCheckBox::checkStateSet()
|
|||
if (state != d->publishedState) {
|
||||
d->publishedState = state;
|
||||
emit checkStateChanged(state);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QT_IGNORE_DEPRECATIONS(
|
||||
emit stateChanged(state);
|
||||
)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ public:
|
|||
void setCheckState(Qt::CheckState state);
|
||||
|
||||
Q_SIGNALS:
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QT_MOC_COMPAT QT_DEPRECATED_VERSION_X_6_9("Use checkStateChanged() instead")
|
||||
void stateChanged(int);
|
||||
#endif
|
||||
void checkStateChanged(Qt::CheckState);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -215,32 +215,42 @@ void tst_QCheckBox::checkStateChanged()
|
|||
|
||||
Qt::CheckState cur_state = Qt::Unchecked;
|
||||
QSignalSpy checkStateChangedSpy(&testWidget, &QCheckBox::checkStateChanged);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QT_IGNORE_DEPRECATIONS(
|
||||
QSignalSpy stateChangedSpy(&testWidget, &QCheckBox::stateChanged);
|
||||
)
|
||||
#endif
|
||||
connect(&testWidget, &QCheckBox::checkStateChanged, this, [&](auto state) { cur_state = state; });
|
||||
testWidget.setChecked(true);
|
||||
QTRY_COMPARE(checkStateChangedSpy.size(), 1);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QCOMPARE(stateChangedSpy.size(), 1);
|
||||
#endif
|
||||
QCOMPARE(cur_state, Qt::Checked);
|
||||
QCOMPARE(testWidget.checkState(), Qt::Checked);
|
||||
|
||||
testWidget.setChecked(false);
|
||||
QTRY_COMPARE(checkStateChangedSpy.size(), 2);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QCOMPARE(stateChangedSpy.size(), 2);
|
||||
#endif
|
||||
QCOMPARE(cur_state, Qt::Unchecked);
|
||||
QCOMPARE(testWidget.checkState(), Qt::Unchecked);
|
||||
|
||||
testWidget.setCheckState(Qt::PartiallyChecked);
|
||||
QTRY_COMPARE(checkStateChangedSpy.size(), 3);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QCOMPARE(stateChangedSpy.size(), 3);
|
||||
#endif
|
||||
QCOMPARE(cur_state, Qt::PartiallyChecked);
|
||||
QCOMPARE(testWidget.checkState(), Qt::PartiallyChecked);
|
||||
|
||||
testWidget.setCheckState(Qt::PartiallyChecked);
|
||||
QCoreApplication::processEvents();
|
||||
QCOMPARE(checkStateChangedSpy.size(), 3);
|
||||
#if QT_DEPRECATED_SINCE(6, 9)
|
||||
QCOMPARE(stateChangedSpy.size(), 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QCheckBox::isToggleButton()
|
||||
|
|
|
|||
Loading…
Reference in New Issue