Account for the item spacing when using QListView::scrollTo()

Somehow this bug managed to stay hidden until the introduction
of QFusionStyle.

Task-number: QTBUG-27675
Change-Id: I86b049b869e9f2951426dc67a485ad7c60ef1403
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Pierre Rossi 2012-11-19 21:15:19 +01:00 committed by The Qt Project
parent e73ac39c99
commit b77749e997
2 changed files with 1 additions and 5 deletions

View File

@ -2546,6 +2546,7 @@ int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int view
if (index < 0)
return scrollValue;
itemExtent += spacing();
QVector<int> visibleFlowPositions;
visibleFlowPositions.reserve(flowPositions.count() - 1);
for (int i = 0; i < flowPositions.count() - 1; i++) { // flowPositions count is +1 larger than actual row count

View File

@ -2196,11 +2196,6 @@ void tst_QListView::taskQTBUG_21804_hiddenItemsAndScrollingWithKeys()
// create listview
QListView lv;
#if !defined(QT_NO_STYLE_WINDOWS)
// The test fails on Fusion style
// See https://bugreports.qt-project.org/browse/QTBUG-27675
lv.setStyle(new QWindowsStyle());
#endif
lv.setFlow(static_cast<QListView::Flow>(flow));
lv.setSpacing(spacing);
lv.setModel(&model);