Qt scroller class (#20549)
* initial commit
* class works
* cleanup
* naming
* text window
* fixes
* alerts are now scrollable
* dismiss
* fixed placement
* realease scrolling
* better
* better
* revert text
* naming
* parent
old-commit-hash: 9afa14c47f
commatwo_master
parent
e95d2f7025
commit
a2e14a8a0c
6 changed files with 59 additions and 20 deletions
@ -0,0 +1,18 @@ |
||||
#include "scrollview.hpp" |
||||
|
||||
ScrollView::ScrollView(QWidget *w, QWidget *parent) : QScrollArea(parent){ |
||||
setWidget(w); |
||||
setWidgetResizable(true); |
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
||||
setStyleSheet("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); |
||||
} |
@ -0,0 +1,11 @@ |
||||
#pragma once |
||||
|
||||
#include <QScroller> |
||||
#include <QScrollArea> |
||||
|
||||
class ScrollView : public QScrollArea { |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit ScrollView(QWidget *w = nullptr, QWidget *parent = nullptr); |
||||
}; |
Loading…
Reference in new issue