QScroller 禁用动态滚动

QScroller disable kinetic scrolling

我的问题很简单。如何使用 QScroller 禁用动态滚动。这是我使用鼠标左键滚动的代码,没有超调。我想,当我停止移动鼠标时,它会停止滚动。

QScroller::grabGesture(ui->scrollArea->viewport(), QScroller::LeftMouseButtonGesture);
QVariant OvershootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff);
QScrollerProperties ScrollerProperties = QScroller::scroller(ui->scrollArea->viewport())->scrollerProperties();
ScrollerProperties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, OvershootPolicy);
ScrollerProperties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, OvershootPolicy);
QScroller::scroller(ui->scrollArea->viewport())->setScrollerProperties(ScrollerProperties);

其实很简单

ScrollerProperties.setScrollMetric(QScrollerProperties::MaximumVelocity, 0);
ScrollerProperties.setScrollMetric(QScrollerProperties::MinimumVelocity, 0);