summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-03-25 11:20:28 +0100
committerLars Knoll <lars.knoll@qt.io>2020-03-25 13:09:38 +0100
commit46ebd11e66f6f3180043a7258b46a1aff79a69f8 (patch)
tree840e53a49d7a0a0c99e99062554c88b702322332 /src/widgets
parentb15ed929f3f481914bf96203e691a552f6d9fe00 (diff)
Fix deprecation of QComboBox:::currentIndexChanged(const QString&)
Don't introduce another overload with two parameters. Users want a simple signal to connect to, not another overload. Deprecate the currentIndexChanged(QString) overload, usage of that can/should get replaced by currentTextChanged(). This partially reverts commit 11dc7b35c8c3957bd19087a5e3ae7cfc4f1a3343. Change-Id: I5e7d16413f3d62b1a5a7a197f510af2c45cdfa55 Reviewed-by: Vitaly Fanaskov <vitaly.fanaskov@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp37
-rw-r--r--src/widgets/widgets/qcombobox.h7
2 files changed, 17 insertions, 27 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index df8e7b4a3f..84ba647975 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -904,7 +904,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
This signal is sent when the user chooses an item in the combobox.
The item's \a index is passed. Note that this signal is sent even
when the choice is not changed. If you need to know when the
- choice actually changes, use signal currentIndexChanged().
+ choice actually changes, use signal currentIndexChanged() or
+ currentTextChanged().
*/
@@ -914,7 +915,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
This signal is sent when the user chooses an item in the combobox.
The item's \a text is passed. Note that this signal is sent even
when the choice is not changed. If you need to know when the
- choice actually changes, use signal currentIndexChanged().
+ choice actually changes, use signal currentIndexChanged() or
+ currentTextChanged().
\obsolete Use QComboBox::textActivated() instead
*/
@@ -925,7 +927,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
This signal is sent when the user chooses an item in the combobox.
The item's \a text is passed. Note that this signal is sent even
when the choice is not changed. If you need to know when the
- choice actually changes, use signal currentIndexChanged().
+ choice actually changes, use signal currentIndexChanged() or
+ currentTextChanged().
*/
/*!
@@ -959,8 +962,6 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
changes either through user interaction or programmatically. The
item's \a index is passed or -1 if the combobox becomes empty or the
currentIndex was reset.
-
- \obsolete Use currentIndexChanged(int index, const QString &text) instead
*/
/*!
@@ -971,17 +972,8 @@ QStyleOptionComboBox QComboBoxPrivateContainer::comboStyleOption() const
changes either through user interaction or programmatically. The
item's \a text is passed.
- \obsolete Use currentIndexChanged(int index, const QString &text) instead
-*/
-
-/*!
- \fn void QComboBox::currentIndexChanged(int index, const QString &text)
- \since 5.15
-
- This signal is sent whenever the currentIndex in the combobox
- changes either through user interaction or programmatically. The
- item's \a index is passed or -1 if the combobox becomes empty or
- the currentIndex was reset. The item's \a text is also passed.
+ \obsolete Use currentIndexChanged(int) and get the text from
+ the itemText(int) method.
*/
/*!
@@ -1013,7 +1005,6 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
d->init();
}
-
/*!
\class QComboBox
\brief The QComboBox widget is a combined button and popup list.
@@ -1036,9 +1027,10 @@ QComboBox::QComboBox(QComboBoxPrivate &dd, QWidget *parent)
to clear the displayed string without changing the combobox's
contents.
- There are two signals emitted if the current item of a combobox
- changes, currentIndexChanged() and activated().
- currentIndexChanged() is always emitted regardless if the change
+ There are three signals emitted if the current item of a combobox
+ changes, currentIndexChanged(), currentTextChanged() and activated().
+ currentIndexChanged() and currentTextChanged() are always emitted
+ regardless if the change
was done programmatically or by user interaction, while
activated() is only emitted when the change is caused by user
interaction. The highlighted() signal is emitted when the user
@@ -1466,14 +1458,13 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index)
{
Q_Q(QComboBox);
const QString text = itemText(index);
-#if QT_DEPRECATED_SINCE(5, 15)
+ emit q->currentIndexChanged(index.row());
+#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
- emit q->currentIndexChanged(index.row());
emit q->currentIndexChanged(text);
QT_WARNING_POP
#endif
- emit q->currentIndexChanged(index.row(), text);
// signal lineEdit.textChanged already connected to signal currentTextChanged, so don't emit double here
if (!lineEdit)
emit q->currentTextChanged(text);
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index e0b213bc89..4d7ca4b635 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -233,13 +233,12 @@ Q_SIGNALS:
void textActivated(const QString &);
void highlighted(int index);
void textHighlighted(const QString &);
-#if QT_DEPRECATED_SINCE(5, 15)
- QT_DEPRECATED_VERSION_X_5_15("Use currentIndexChanged(int, const QString &) instead")
void currentIndexChanged(int index);
- QT_DEPRECATED_VERSION_X_5_15("Use currentIndexChanged(int, const QString &) instead")
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15(
+ "Use currentIndexChanged(int) instead, and get the text using itemText(index)")
void currentIndexChanged(const QString &);
#endif
- void currentIndexChanged(int index, const QString &text);
void currentTextChanged(const QString &);
#if QT_DEPRECATED_SINCE(5, 15)
QT_DEPRECATED_VERSION_X(5, 15, "Use textActivated() instead")