Important: Please read the Qt Code of Conduct -

Scrolling through the QListView items !

  • I have a QListView which has a horizontal scroll bar. When I drag and drop an item, the scroll bar should move to the appropriate position as per the cursor position.


    But when the mouse cursor is at the end of the viewport of the qlistview, scrolling stops. The problem is scroll bar doesnt get the "x" position at the end of the qlistview's viewport.

  • Moderators

    This is not trivial, since you cannot get mouse events if the drag for instance leaves the application window boundaries...
    the only possibility to overcome this problem would be to subclass qlistview, override "QAbstractItemView::startDrag()": and do the same like QListView does in there.
    Once the drag starts you need to poll the cursor position with a timer and adapt the scrolling.
    But this solution also only works for drags started in the list itself (no external drags).

Log in to reply