QGIS API Documentation 3.27.0-Master (f261cc1f8b)
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
41class GUI_EXPORT QgsScrollArea : public QScrollArea
42{
43 Q_OBJECT
44
45 public:
46
50 explicit QgsScrollArea( QWidget *parent SIP_TRANSFERTHIS = nullptr );
51
56 void scrollOccurred();
57
62 bool hasScrolled() const;
63
69 void resetHasScrolled() SIP_SKIP;
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 QTimer mTimer;
87 ScrollAreaFilter *mFilter = nullptr;
88 bool mVerticalOnly = false;
89
90};
91
92#ifndef SIP_RUN
93
95
101class ScrollAreaFilter : public QObject
102{
103 Q_OBJECT
104 public:
105
106 ScrollAreaFilter( QgsScrollArea *parent = nullptr,
107 QWidget *viewPort = nullptr );
108
109 protected:
110 bool eventFilter( QObject *obj, QEvent *event ) override;
111
112 private:
113 QgsScrollArea *mScrollAreaWidget = nullptr;
114 QWidget *mViewPort = nullptr;
115 QPoint mPreviousViewportCursorPos;
116 int mMoveDistanceThreshold = 0;
117
118 void addChild( QObject *child );
119 void removeChild( QObject *child );
120
121};
122
124
125#endif
126
127#endif // QGSSCROLLAREA_H
A QScrollArea subclass with improved scrolling behavior.
Definition: qgsscrollarea.h:42
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126