Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
4.5.0
-
None
Description
t4id: 250084
If a subclass of QAbstractItemView is configured with autoscroll(true) and the selection mode select the whole row on selection, the autoscrolling should not scroll horizontally. The row are considered as a single entity so scrolling horizontally is a strange behavior.
Here is an example to show the problem, if you click somewhere in the second column, you don't expect the view to scroll horitontally.
#include <QtGui>
#include <QtCore>
int main(int argc, char **argv){
QApplication app(argc, argv);
QStandardItemModel model(10, 2);
for (int row = 0; row < 10; ++row) {
for (int column = 0; column < 2; ++column)
}
QTreeView view;
view.setAutoScroll(true);
view.setAllColumnsShowFocus(true);
view.setModel(&model);
view.setColumnWidth(1, 200);
view.setColumnWidth(2, 1000);
view.show();
return app.exec();
}
Here is a patch to avoid the horizontal scrolling when the selection model is by row:
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 26bf20f..cbf31e5 100644
— a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -2210,8 +2210,15 @@ void QAbstractItemView::timerEvent(QTimerEvent *event)
d->delayedAutoScroll.stop();
//end of the timer: if the current item is still the same as the one when the mouse press occurred
//we only get here if there was no double click
- if (d->pressedIndex.isValid() && d->pressedIndex == currentIndex())
- scrollTo(d->pressedIndex);
+ if (d->pressedIndex.isValid() && d->pressedIndex == currentIndex())Unknown macro: {+ if (d->selectionBehavior == QAbstractItemView}}
}
@@ -2311,7 +2318,6 @@ bool QAbstractItemView::edit(const QModelIndex &index, EditTrigger trigger, QEve
w->setFocus();
return true;
}
-
if (trigger == DoubleClicked)
}
if (isVisible() && current.isValid() && !d->autoScrollTimer.isActive()) {
- if (d->autoScroll)
- scrollTo(current);
+ if (d->autoScroll)Unknown macro: {+ if (d->selectionBehavior == QAbstractItemView}d->setDirtyRegion(visualRect(current));
d->updateDirtyRegion();
edit(current, CurrentChanged, 0);