QHeaderView - fix a logical / visual index mismatch

f9408317e7 was unfortunately
approved though it had an annoying bug. The patch had
an assign of a visual index into a logical index.

This patch fixes that issue.

Change-Id: I9cc75e4e9701858c92e2c3e5817415041b42f8e8
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
This commit is contained in:
Thorbjørn Martsum 2015-06-26 07:17:03 +02:00 committed by Thorbjørn Lund Martsum
parent 12b36aec2b
commit f1b01b7d15
2 changed files with 4 additions and 2 deletions

View File

@ -2450,7 +2450,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
case QHeaderViewPrivate::SelectSections: {
int logical = logicalIndexAt(qMax(-d->offset, pos));
if (logical == -1 && pos > 0)
logical = d->lastVisibleVisualIndex();
logical = logicalIndex(d->lastVisibleVisualIndex());
if (logical == d->pressed)
return; // nothing to do
else if (d->pressed != -1)

View File

@ -140,10 +140,12 @@ private:
QTableView *setupTableView()
{
tableView = new QTableView;
m.setRowCount(500);
const int rowCount = 200;
m.setRowCount(rowCount);
m.setColumnCount(250);
tableView->setSelectionMode(QAbstractItemView::SingleSelection);
tableView->setModel(&m);
tableView->verticalHeader()->swapSections(rowCount - 1, 5);
return tableView;
}