I have a QListView with a horizontal scroll bar in which QStandardItems are inserted. When I drag an item over the existing items the scroll bar moves as per the QModelIndex. But when i reach the end of the listview ,the scroll bar does’nt move to the exact end of the listview.There is some 3 to 4 pixels gap. The same problem appears when I scroll to beginning of the listview. How to scroll to the exact end or beginning of the listview during dragMoveEvent?
Asked
Active
Viewed 647 times
1 Answers
0
When autoScroll
is enabled, the view uses the scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible)
method to display the QModelIndex
you are over, but it doesn't take into account the item view margin (between the items and the view frame).
You will need to reimplement dragMoveEvent(QDragMoveEvent* event)
to check if the hovered QModelIndex
is the last in the row, and if it is then move the scrollbar to the appropriate end.

cmannett85
- 21,725
- 8
- 76
- 119