File indexing completed on 2025-09-16 09:06:30
0001
0002
0003
0004 #ifndef QSCROLLER_H
0005 #define QSCROLLER_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtCore/QObject>
0009 #include <QtCore/QPointF>
0010 #include <QtWidgets/QScrollerProperties>
0011
0012 class tst_QScroller;
0013
0014 QT_REQUIRE_CONFIG(scroller);
0015
0016 QT_BEGIN_NAMESPACE
0017
0018
0019 class QWidget;
0020 class QScrollerPrivate;
0021 class QScrollerProperties;
0022 #ifndef QT_NO_GESTURES
0023 class QFlickGestureRecognizer;
0024 class QMouseFlickGestureRecognizer;
0025 #endif
0026
0027 class Q_WIDGETS_EXPORT QScroller : public QObject
0028 {
0029 Q_OBJECT
0030 Q_PROPERTY(State state READ state NOTIFY stateChanged)
0031 Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties
0032 WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
0033
0034 public:
0035 enum State
0036 {
0037 Inactive,
0038 Pressed,
0039 Dragging,
0040 Scrolling
0041 };
0042 Q_ENUM(State)
0043
0044 enum ScrollerGestureType
0045 {
0046 TouchGesture,
0047 LeftMouseButtonGesture,
0048 RightMouseButtonGesture,
0049 MiddleMouseButtonGesture
0050 };
0051
0052 enum Input
0053 {
0054 InputPress = 1,
0055 InputMove,
0056 InputRelease
0057 };
0058
0059 static bool hasScroller(QObject *target);
0060
0061 static QScroller *scroller(QObject *target);
0062 static const QScroller *scroller(const QObject *target);
0063
0064 #ifndef QT_NO_GESTURES
0065 static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
0066 static Qt::GestureType grabbedGesture(QObject *target);
0067 static void ungrabGesture(QObject *target);
0068 #endif
0069
0070 static QList<QScroller *> activeScrollers();
0071
0072 QObject *target() const;
0073
0074 State state() const;
0075
0076 bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
0077
0078 void stop();
0079 QPointF velocity() const;
0080 QPointF finalPosition() const;
0081 QPointF pixelPerMeter() const;
0082
0083 QScrollerProperties scrollerProperties() const;
0084
0085 void setSnapPositionsX( const QList<qreal> &positions );
0086 void setSnapPositionsX( qreal first, qreal interval );
0087 void setSnapPositionsY( const QList<qreal> &positions );
0088 void setSnapPositionsY( qreal first, qreal interval );
0089
0090 public Q_SLOTS:
0091 void setScrollerProperties(const QScrollerProperties &prop);
0092 void scrollTo(const QPointF &pos);
0093 void scrollTo(const QPointF &pos, int scrollTime);
0094 void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
0095 void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
0096 void resendPrepareEvent();
0097
0098 Q_SIGNALS:
0099 void stateChanged(QScroller::State newstate);
0100 void scrollerPropertiesChanged(const QScrollerProperties &);
0101
0102 private:
0103 QScrollerPrivate *d_ptr;
0104
0105 QScroller(QObject *target);
0106 virtual ~QScroller();
0107
0108 Q_DISABLE_COPY(QScroller)
0109 Q_DECLARE_PRIVATE(QScroller)
0110
0111 friend class ::tst_QScroller;
0112 #ifndef QT_NO_GESTURES
0113 friend class QFlickGestureRecognizer;
0114 #endif
0115 };
0116
0117 QT_END_NAMESPACE
0118
0119 #endif