QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
48 explicit QgsScrollArea( QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
54 void scrollOccurred();
55
60 bool hasScrolled() const;
61
67 void resetHasScrolled() SIP_SKIP;
68
77 void setVerticalOnly( bool verticalOnly );
78
79 protected:
80 void wheelEvent( QWheelEvent *event ) override;
81 void resizeEvent( QResizeEvent *event ) override;
82
83 private:
84 QTimer mTimer;
85 ScrollAreaFilter *mFilter = nullptr;
86 bool mVerticalOnly = false;
87};
88
89#ifndef SIP_RUN
90
92
98class ScrollAreaFilter : public QObject
99{
100 Q_OBJECT
101 public:
102 ScrollAreaFilter( QgsScrollArea *parent = nullptr, QWidget *viewPort = nullptr );
103
104 protected:
105 bool eventFilter( QObject *obj, QEvent *event ) override;
106
107 private:
108 QgsScrollArea *mScrollAreaWidget = nullptr;
109 QWidget *mViewPort = nullptr;
110 QPoint mPreviousViewportCursorPos;
111 int mMoveDistanceThreshold = 0;
112
113 void addChild( QObject *child );
114 void removeChild( QObject *child );
115};
116
118
119#endif
120
121#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