QTreeView: fix keyboard navigation when using the right arrow key

The visual column index needs to be replaced by the logical column
index in QModelIndex::sibling() call in QTreeView::moveCursor() method.

[ChangeLog][QtWidgets][QTreeView] Fixed a key navigation bug
when the columns were reordered.

Task-number: QTBUG-52793
Change-Id: I4dc89a2705966a94b20edd7f9a4422f089bb670f
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
Kaligin Sergey 2016-05-11 14:46:47 +03:00 committed by Thorbjørn Lund Martsum
parent 797cd4b7bc
commit 5d31c9831d

View File

@ -2314,8 +2314,8 @@ QModelIndex QTreeView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifie
int visualColumn = d->header->visualIndex(current.column()) + 1;
while (visualColumn < d->model->columnCount(current.parent()) && isColumnHidden(d->header->logicalIndex(visualColumn)))
visualColumn++;
QModelIndex next = current.sibling(current.row(), visualColumn);
const int newColumn = d->header->logicalIndex(visualColumn);
const QModelIndex next = current.sibling(current.row(), newColumn);
if (next.isValid())
return next;
}