QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 <QScrollArea>
20#include "qgis_sip.h"
21#include "qgis_gui.h"
22#include <QTimer>
23class ScrollAreaFilter;
24
40class GUI_EXPORT QgsScrollArea : public QScrollArea
41{
42 Q_OBJECT
43
44 public:
45
49 explicit QgsScrollArea( QWidget *parent SIP_TRANSFERTHIS = nullptr );
50
55 void scrollOccurred();
56
61 bool hasScrolled() const;
62
68 void resetHasScrolled() SIP_SKIP;
69
78 void setVerticalOnly( bool verticalOnly );
79
80 protected:
81 void wheelEvent( QWheelEvent *event ) override;
82 void resizeEvent( QResizeEvent *event ) override;
83
84 private:
85 QTimer mTimer;
86 ScrollAreaFilter *mFilter = nullptr;
87 bool mVerticalOnly = false;
88
89};
90
91#ifndef SIP_RUN
92
94
100class ScrollAreaFilter : public QObject
101{
102 Q_OBJECT
103 public:
104
105 ScrollAreaFilter( QgsScrollArea *parent = nullptr,
106 QWidget *viewPort = nullptr );
107
108 protected:
109 bool eventFilter( QObject *obj, QEvent *event ) override;
110
111 private:
112 QgsScrollArea *mScrollAreaWidget = nullptr;
113 QWidget *mViewPort = nullptr;
114 QPoint mPreviousViewportCursorPos;
115 int mMoveDistanceThreshold = 0;
116
117 void addChild( QObject *child );
118 void removeChild( QObject *child );
119
120};
121
123
124#endif
125
126#endif // QGSSCROLLAREA_H
A QScrollArea subclass with improved scrolling behavior.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126