diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-11-23 15:32:55 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-12-02 14:16:49 +0000 |
commit | d22bafe3559afef1dcab1c9076f82ac224d012b6 (patch) | |
tree | 32b8130d16e2297f23dff4a9b8f61ce5bb8c6cda /src/widgets/itemviews | |
parent | 97cfd4940157817dd761fd02f2e6da4afc5b4a30 (diff) | |
download | qtbase-d22bafe3559afef1dcab1c9076f82ac224d012b6.tar.gz |
QTableView: correctly toggle column selection when scrolled
We need to check whether the horizontal header's selection includes the
index for the row at the top, rather than for row 0, as the index we
check is based on the scrolled position of the header, so would never be
included in the top row when the view is scrolled. This is correctly
done in selectRow already.
Add a test case that simulates selection of rows and columns by clicking
on the header.
Fixes: QTBUG-98444
Pick-to: 6.2
Change-Id: I2fa1b32bf75dc96225b40145b713bf7e2ffc29dd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r-- | src/widgets/itemviews/qtableview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 62bc9d1ff1..d1b82c2511 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -3467,7 +3467,7 @@ void QTableViewPrivate::selectColumn(int column, bool anchor) if (q->selectionMode() != QTableView::SingleSelection && command.testFlag(QItemSelectionModel::Toggle)) { if (anchor) - ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns().contains(index) + ctrlDragSelectionFlag = horizontalHeader->selectionModel()->selectedColumns(row).contains(index) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select; command &= ~QItemSelectionModel::Toggle; command |= ctrlDragSelectionFlag; |