Qt how to stop dragging viewport of QListView when using QScroller

qlistview, qt, scroll

Solution

You have to set the overshoot policy of the `QScrollerProperties`. Here an example for the vertical scrolling:

QScrollerProperties properties = QScroller::scroller(scrollWidget)->scrollerProperties();

QVariant overshootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff);
properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, overshootPolicy);

QScroller::scroller(scrollWidget)->setScrollerProperties(properties); 

Problem

I'm using QScroller on my QListView. How can I stop dragging the list away when it reaches its beginning or its end? Like image below.

Original source