QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsscrollarea.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscrollarea.h
3 ---------------
4 begin : March 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSSCROLLAREA_H
17#define QGSSCROLLAREA_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QElapsedTimer>
23#include <QScrollArea>
24
25class ScrollAreaFilter;
26
42class GUI_EXPORT QgsScrollArea : public QScrollArea
43{
44 Q_OBJECT
45
46 public:
50 explicit QgsScrollArea( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51
56 void scrollOccurred();
57
62 bool hasScrolled() const;
63
70
79 void setVerticalOnly( bool verticalOnly );
80
81 protected:
82 void wheelEvent( QWheelEvent *event ) override;
83 void resizeEvent( QResizeEvent *event ) override;
84
85 private:
86 bool mTimerActive = false;
87 QElapsedTimer mTimer;
88 ScrollAreaFilter *mFilter = nullptr;
89 bool mVerticalOnly = false;
90};
91
92#ifndef SIP_RUN
93
95
101class ScrollAreaFilter : public QObject
102{
103 Q_OBJECT
104 public:
105 ScrollAreaFilter( QgsScrollArea *parent = nullptr, QWidget *viewPort = nullptr );
106
107 protected:
108 bool eventFilter( QObject *obj, QEvent *event ) override;
109
110 private:
111 QgsScrollArea *mScrollAreaWidget = nullptr;
112 QWidget *mViewPort = nullptr;
113 QPoint mPreviousViewportCursorPos;
114 int mMoveDistanceThreshold = 0;
115
116 void addChild( QObject *child );
117 void removeChild( QObject *child );
118};
119
121
122#endif
123
124#endif // QGSSCROLLAREA_H
A QScrollArea subclass with improved scrolling behavior.
void setVerticalOnly(bool verticalOnly)
Sets whether the scroll area only applies vertical.
QgsScrollArea(QWidget *parent=nullptr)
Constructor for QgsScrollArea.
void resetHasScrolled()
Resets the hasScrolled() flag.
bool hasScrolled() const
Returns true if a scroll recently occurred within the QScrollArea or its child viewport().
void wheelEvent(QWheelEvent *event) override
void scrollOccurred()
Should be called when a scroll occurs on with the QScrollArea itself or its child viewport().
void resizeEvent(QResizeEvent *event) override
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134