mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-15 06:12:11 +08:00
c671dca363
old-commit-hash: 204d878c6f538891f36073cf364f14c6561126d9
19 lines
903 B
C++
19 lines
903 B
C++
#include "scrollview.hpp"
|
|
|
|
ScrollView::ScrollView(QWidget *w, QWidget *parent) : QScrollArea(parent){
|
|
setWidget(w);
|
|
setWidgetResizable(true);
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setStyleSheet("ScrollView { background-color:transparent; }");
|
|
|
|
QScroller *scroller = QScroller::scroller(this->viewport());
|
|
QScrollerProperties sp = scroller->scrollerProperties();
|
|
|
|
sp.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff));
|
|
sp.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, QVariant::fromValue<QScrollerProperties::OvershootPolicy>(QScrollerProperties::OvershootAlwaysOff));
|
|
|
|
scroller->grabGesture(this->viewport(), QScroller::LeftMouseButtonGesture);
|
|
scroller->setScrollerProperties(sp);
|
|
}
|