Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt how to stop dragging viewport of QListView when using QScroller

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. enter image description here

like image 521
Mike Shaw Avatar asked Jul 10 '14 12:07

Mike Shaw


1 Answers

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); 
like image 166
tomvodi Avatar answered Sep 22 '22 21:09

tomvodi