QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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>
23 class ScrollAreaFilter;
24 
41 class 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 
72  void setVerticalOnly( bool verticalOnly );
73 
74  protected:
75  void wheelEvent( QWheelEvent *event ) override;
76  void resizeEvent( QResizeEvent *event ) override;
77 
78  private:
79  QTimer mTimer;
80  ScrollAreaFilter *mFilter = nullptr;
81  bool mVerticalOnly = false;
82 
83 };
84 
85 #ifndef SIP_RUN
86 
88 
94 class ScrollAreaFilter : public QObject
95 {
96  Q_OBJECT
97  public:
98 
99  ScrollAreaFilter( QgsScrollArea *parent = nullptr,
100  QWidget *viewPort = nullptr );
101 
102  protected:
103  bool eventFilter( QObject *obj, QEvent *event ) override;
104 
105  private:
106  QgsScrollArea *mScrollAreaWidget = nullptr;
107  QWidget *mViewPort = nullptr;
108 
109  void addChild( QObject *child );
110  void removeChild( QObject *child );
111 
112 };
113 
115 
116 #endif
117 
118 #endif // QGSSCROLLAREA_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
A QScrollArea subclass with improved scrolling behavior.
Definition: qgsscrollarea.h:41