summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2021-01-12 20:58:05 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-13 19:34:32 +0000
commit3f2b5fdf48e32ee01bcc1154adef5b3c530fb9bc (patch)
tree8d87d6ccd231bd76853b61405333041e18b057a3 /src
parent1e5c279c22c8744cbcedabf70a5b526a84b5302f (diff)
QComboBox: fix select all columns in the view
When the QComboBox gets a custom view with multiple columns, only the first one is selected even the selection mode of the view is SelectRows. The selection changes afterwards properly honor the mode though. Therefore check for the selection mode and call setCurrentIndex() with the appropriate flags. Fixes: QTBUG-86776 Change-Id: Ieba7b9e009358e7b6e802b7847640161ec776c64 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit b3b28faf2627aad3a0c47fb4c7c711e0d19984aa) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qcombobox.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index f2baa5f8e8..65017be384 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -2607,8 +2607,10 @@ void QComboBox::showPopup()
#endif
// set current item and select it
- view()->selectionModel()->setCurrentIndex(d->currentIndex,
- QItemSelectionModel::ClearAndSelect);
+ QItemSelectionModel::SelectionFlags selectionMode = QItemSelectionModel::ClearAndSelect;
+ if (view()->selectionBehavior() == QAbstractItemView::SelectRows)
+ selectionMode.setFlag(QItemSelectionModel::Rows);
+ view()->selectionModel()->setCurrentIndex(d->currentIndex, selectionMode);
QComboBoxPrivateContainer* container = d->viewContainer();
QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this));