Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QScroller Class Reference

The QScroller class enables kinetic scrolling for any scrolling widget or graphics item. More...

#include <qscroller.h>

+ Inheritance diagram for QScroller:
+ Collaboration diagram for QScroller:

Public Types

enum  State { Inactive , Pressed , Dragging , Scrolling }
 This enum contains the different QScroller states. More...
 
enum  ScrollerGestureType { TouchGesture , LeftMouseButtonGesture , RightMouseButtonGesture , MiddleMouseButtonGesture }
 This enum contains the different gesture types that are supported by the QScroller gesture recognizer. More...
 
enum  Input { InputPress = 1 , InputMove , InputRelease }
 This enum contains an input device agnostic view of input events that are relevant for QScroller. More...
 

Public Slots

void setScrollerProperties (const QScrollerProperties &prop)
 
void scrollTo (const QPointF &pos)
 Starts scrolling the widget so that point pos is at the top-left position in the viewport.
 
void scrollTo (const QPointF &pos, int scrollTime)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version will reach its destination position in scrollTime milliseconds.
 
void ensureVisible (const QRectF &rect, qreal xmargin, qreal ymargin)
 Starts scrolling so that the rectangle rect is visible inside the viewport with additional margins specified in pixels by xmargin and ymargin around the rect.
 
void ensureVisible (const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version will reach its destination position in scrollTime milliseconds.
 
void resendPrepareEvent ()
 This function resends the QScrollPrepareEvent.
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 

Signals

void stateChanged (QScroller::State newstate)
 QScroller emits this signal whenever the state changes.
 
void scrollerPropertiesChanged (const QScrollerProperties &)
 QScroller emits this signal whenever its scroller properties change.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

QObjecttarget () const
 Returns the target object of this scroller.
 
State state () const
 
bool handleInput (Input input, const QPointF &position, qint64 timestamp=0)
 This function is used by gesture recognizers to inform the scroller about a new input event.
 
void stop ()
 Stops the scroller and resets its state back to Inactive.
 
QPointF velocity () const
 Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging.
 
QPointF finalPosition () const
 Returns the estimated final position for the current scroll movement.
 
QPointF pixelPerMeter () const
 Returns the pixel per meter metric for the scrolled widget.
 
QScrollerProperties scrollerProperties () const
 
void setSnapPositionsX (const QList< qreal > &positions)
 Set the snap positions for the horizontal axis to a list of positions.
 
void setSnapPositionsX (qreal first, qreal interval)
 Set the snap positions for the horizontal axis to regular spaced intervals.
 
void setSnapPositionsY (const QList< qreal > &positions)
 Set the snap positions for the vertical axis to a list of positions.
 
void setSnapPositionsY (qreal first, qreal interval)
 Set the snap positions for the vertical axis to regular spaced intervals.
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Static Public Member Functions

static bool hasScroller (QObject *target)
 Returns true if a QScroller object was already created for target; false otherwise.
 
static QScrollerscroller (QObject *target)
 Returns the scroller for the given target.
 
static const QScrollerscroller (const QObject *target)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This is the const version of scroller().
 
static Qt::GestureType grabGesture (QObject *target, ScrollerGestureType gestureType=TouchGesture)
 Registers a custom scroll gesture recognizer, grabs it for the target and returns the resulting gesture type.
 
static Qt::GestureType grabbedGesture (QObject *target)
 Returns the gesture type currently grabbed for the target or 0 if no gesture is grabbed.
 
static void ungrabGesture (QObject *target)
 Ungrabs the gesture for the target.
 
static QList< QScroller * > activeScrollers ()
 Returns an application wide list of currently active QScroller objects.
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Properties

State state
 the state of the scroller
 
QScrollerProperties scrollerProperties
 The scroller properties of this scroller.
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Private Member Functions

virtual ~QScroller ()
 

Friends

class QFlickGestureRecognizer
 

Additional Inherited Members

- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.

Since
5.0

\inmodule QtWidgets

With kinetic scrolling, the user can push the widget in a given direction and it will continue to scroll in this direction until it is stopped either by the user or by friction. Aspects of inertia, friction and other physical concepts can be changed in order to fine-tune an intuitive user experience.

The QScroller object is the object that stores the current position and scrolling speed and takes care of updates. QScroller can be triggered by a flick gesture

or directly like this:

QWidget *w = ...;
scroller->scrollTo(QPointF(100, 100));
The QScroller class enables kinetic scrolling for any scrolling widget or graphics item.
Definition qscroller.h:26
static QScroller * scroller(QObject *target)
Returns the scroller for the given target.
static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType=TouchGesture)
Registers a custom scroll gesture recognizer, grabs it for the target and returns the resulting gestu...
void scrollTo(const QPointF &pos)
Starts scrolling the widget so that point pos is at the top-left position in the viewport.
@ LeftMouseButtonGesture
Definition qscroller.h:45
QScroller * scroller

The scrolled QObjects receive a QScrollPrepareEvent whenever the scroller needs to update its geometry information and a QScrollEvent whenever the content of the object should actually be scrolled.

The scroller uses the global QAbstractAnimation timer to generate its QScrollEvents. This can be changed with QScrollerProperties::FrameRate on a per-QScroller basis.

Even though this kinetic scroller has a large number of settings available via QScrollerProperties, we recommend that you leave them all at their default, platform optimized values. Before changing them you can experiment with the plot example in the scroller examples directory.

See also
QScrollEvent, QScrollPrepareEvent, QScrollerProperties

Definition at line 25 of file qscroller.h.

Member Enumeration Documentation

◆ Input

This enum contains an input device agnostic view of input events that are relevant for QScroller.

\value InputPress The user pressed the input device (e.g. QEvent::MouseButtonPress, QEvent::GraphicsSceneMousePress, QEvent::TouchBegin)

\value InputMove The user moved the input device (e.g. QEvent::MouseMove, QEvent::GraphicsSceneMouseMove, QEvent::TouchUpdate)

\value InputRelease The user released the input device (e.g. QEvent::MouseButtonRelease, QEvent::GraphicsSceneMouseRelease, QEvent::TouchEnd)

Enumerator
InputPress 
InputMove 
InputRelease 

Definition at line 50 of file qscroller.h.

◆ ScrollerGestureType

This enum contains the different gesture types that are supported by the QScroller gesture recognizer.

\value TouchGesture The gesture recognizer will only trigger on touch events. Specifically it will react on single touch points when using a touch screen and dual touch points when using a touchpad. \value LeftMouseButtonGesture The gesture recognizer will only trigger on left mouse button events. \value MiddleMouseButtonGesture The gesture recognizer will only trigger on middle mouse button events. \value RightMouseButtonGesture The gesture recognizer will only trigger on right mouse button events.

Enumerator
TouchGesture 
LeftMouseButtonGesture 
RightMouseButtonGesture 
MiddleMouseButtonGesture 

Definition at line 42 of file qscroller.h.

◆ State

This enum contains the different QScroller states.

\value Inactive The scroller is not scrolling and nothing is pressed. \value Pressed A touch event was received or the mouse button was pressed but the scroll area is currently not dragged. \value Dragging The scroll area is currently following the touch point or mouse. \value Scrolling The scroll area is moving on it's own.

Enumerator
Inactive 
Pressed 
Dragging 
Scrolling 

Definition at line 33 of file qscroller.h.

Member Function Documentation

◆ ~QScroller()

QScroller::~QScroller ( )
privatevirtual

Definition at line 455 of file qscroller.cpp.

References d, and QGestureRecognizer::unregisterRecognizer().

+ Here is the call graph for this function:

◆ activeScrollers()

QList< QScroller * > QScroller::activeScrollers ( )
static

Returns an application wide list of currently active QScroller objects.

Active QScroller objects are in a state() that is not QScroller::Inactive. This function is useful when writing your own gesture recognizer.

Definition at line 284 of file qscroller.cpp.

Referenced by QFlickGestureRecognizer::recognize().

+ Here is the caller graph for this function:

◆ ensureVisible [1/2]

void QScroller::ensureVisible ( const QRectF & rect,
qreal xmargin,
qreal ymargin )
slot

Starts scrolling so that the rectangle rect is visible inside the viewport with additional margins specified in pixels by xmargin and ymargin around the rect.

In cases where it is not possible to fit the rect plus margins inside the viewport the contents are scrolled so that as much as possible is visible from rect.

The scrolling speed is calculated so that the given position is reached after a platform-defined time span.

This function performs the actual scrolling by calling scrollTo().

See also
scrollTo()

Definition at line 686 of file qscroller.cpp.

References ensureVisible(), and rect.

Referenced by ensureVisible().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensureVisible [2/2]

void QScroller::ensureVisible ( const QRectF & rect,
qreal xmargin,
qreal ymargin,
int scrollTime )
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version will reach its destination position in scrollTime milliseconds.

Definition at line 696 of file qscroller.cpp.

References clampToRect(), d, Dragging, QSizeF::height(), Qt::Horizontal, Inactive, Pressed, qCDebug, rect, scrollTo(), QPointF::setX(), QPointF::setY(), Qt::Vertical, and QSizeF::width().

+ Here is the call graph for this function:

◆ finalPosition()

QPointF QScroller::finalPosition ( ) const

Returns the estimated final position for the current scroll movement.

Returns the current position if the scroller state is not Scrolling. The result is undefined when the scroller state is Inactive.

The target position is in pixel.

See also
pixelPerMeter(), scrollTo()

Definition at line 601 of file qscroller.cpp.

References d, Qt::Horizontal, and Qt::Vertical.

◆ grabbedGesture()

Qt::GestureType QScroller::grabbedGesture ( QObject * target)
static

Returns the gesture type currently grabbed for the target or 0 if no gesture is grabbed.

See also
grabGesture(), ungrabGesture()

Definition at line 399 of file qscroller.cpp.

References scroller.

◆ grabGesture()

Qt::GestureType QScroller::grabGesture ( QObject * target,
ScrollerGestureType scrollGestureType = TouchGesture )
static

Registers a custom scroll gesture recognizer, grabs it for the target and returns the resulting gesture type.

If scrollGestureType is set to TouchGesture the gesture triggers on touch events. If it is set to one of LeftMouseButtonGesture, RightMouseButtonGesture or MiddleMouseButtonGesture it triggers on mouse events of the corresponding button.

Only one scroll gesture can be active on a single object at the same time. If you call this function twice on the same object, it will ungrab the existing gesture before grabbing the new one.

Note
To avoid unwanted side-effects, mouse events are consumed while the gesture is triggered. Since the initial mouse press event is not consumed, the gesture sends a fake mouse release event at the global position {(INT_MIN, INT_MIN)}. This ensures that internal states of the widget that received the original mouse press are consistent.
See also
ungrabGesture(), grabbedGesture()

Definition at line 355 of file qscroller.cpp.

References button, QWidget::grabGesture(), Qt::LeftButton, LeftMouseButtonGesture, Qt::MiddleButton, MiddleMouseButtonGesture, Qt::NoButton, QFlickGestureRecognizer, QGestureRecognizer::registerRecognizer(), Qt::RightButton, RightMouseButtonGesture, scroller, QWidget::setAttribute(), sp, target(), TouchGesture, ungrabGesture(), Qt::WA_AcceptTouchEvents, and widget.

Referenced by QPixmapStyle::polish().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleInput()

bool QScroller::handleInput ( Input input,
const QPointF & position,
qint64 timestamp = 0 )

This function is used by gesture recognizers to inform the scroller about a new input event.

The scroller changes its internal state() according to the input event and its attached scroller properties. The scroller doesn't distinguish between the kind of input device the event came from. Therefore the event needs to be split into the input type, a position and a milli-second timestamp. The position needs to be in the target's coordinate system.

The return value is true if the event should be consumed by the calling filter or false if the event should be forwarded to the control.

Note
Using grabGesture() should be sufficient for most use cases.

Definition at line 942 of file qscroller.cpp.

References d, Dragging, i, Inactive, InputMove, InputPress, InputRelease, QScrollerPrivate::moveWhileDragging(), QScrollerPrivate::moveWhilePressed(), position(), Pressed, QScrollerPrivate::pressWhileInactive(), QScrollerPrivate::pressWhileScrolling(), qCDebug, QScrollerPrivate::releaseWhileDragging(), QScrollerPrivate::releaseWhilePressed(), Scrolling, and state.

Referenced by QFlickGestureRecognizer::recognize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasScroller()

bool QScroller::hasScroller ( QObject * target)
static

Returns true if a QScroller object was already created for target; false otherwise.

See also
scroller()

Definition at line 242 of file qscroller.cpp.

Referenced by QFlickGesture::QFlickGesture().

+ Here is the caller graph for this function:

◆ pixelPerMeter()

QPointF QScroller::pixelPerMeter ( ) const

Returns the pixel per meter metric for the scrolled widget.

The value is reported for both the x and y axis separately by using a QPointF.

Note
Please note that this value should be physically correct. The actual DPI settings that Qt returns for the display may be reported wrongly on purpose by the underlying windowing system, for example on \macos.

Definition at line 521 of file qscroller.cpp.

References d, QList< T >::first(), QLineF::length(), scene, tr, QGraphicsView::viewportTransform(), and QGraphicsScene::views().

+ Here is the call graph for this function:

◆ resendPrepareEvent

void QScroller::resendPrepareEvent ( )
slot

This function resends the QScrollPrepareEvent.

Calling resendPrepareEvent triggers a QScrollPrepareEvent from the scroller. This allows the receiver to re-set content position and content size while scrolling. Calling this function while in the Inactive state is useless as the prepare event is sent again before scrolling starts.

Definition at line 770 of file qscroller.cpp.

References d.

◆ scroller() [1/2]

const QScroller * QScroller::scroller ( const QObject * target)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This is the const version of scroller().

Definition at line 274 of file qscroller.cpp.

References scroller.

◆ scroller() [2/2]

QScroller * QScroller::scroller ( QObject * target)
static

Returns the scroller for the given target.

As long as the object exists this function will always return the same QScroller instance. If no QScroller exists for the target, one will implicitly be created. At no point more than one QScroller will be active on an object.

See also
hasScroller(), target()

Definition at line 255 of file qscroller.cpp.

References contains(), and qWarning.

Referenced by QFlickGesture::QFlickGesture(), and QAbstractItemView::viewportEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scrollerProperties()

QScrollerProperties QScroller::scrollerProperties ( ) const

Definition at line 313 of file qscroller.cpp.

References d.

◆ scrollerPropertiesChanged

void QScroller::scrollerPropertiesChanged ( const QScrollerProperties & newProperties)
signal

QScroller emits this signal whenever its scroller properties change.

newProperties are the new scroller properties.

See also
scrollerProperties

Referenced by setScrollerProperties().

+ Here is the caller graph for this function:

◆ scrollTo [1/2]

void QScroller::scrollTo ( const QPointF & pos)
slot

Starts scrolling the widget so that point pos is at the top-left position in the viewport.

The behaviour when scrolling outside the valid scroll area is undefined. In this case the scroller might or might not overshoot.

The scrolling speed will be calculated so that the given position will be reached after a platform-defined time span.

pos is given in viewport coordinates.

See also
ensureVisible()

Definition at line 622 of file qscroller.cpp.

References pos, and scrollTo().

Referenced by ensureVisible(), and scrollTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scrollTo [2/2]

void QScroller::scrollTo ( const QPointF & pos,
int scrollTime )
slot

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This version will reach its destination position in scrollTime milliseconds.

Definition at line 632 of file qscroller.cpp.

References clampToRect(), d, Dragging, Qt::Horizontal, Inactive, pos, Pressed, qCDebug, qIsNaN(), Scrolling, QScrollerPrivate::ScrollTypeScrollTo, time, velocity(), and Qt::Vertical.

+ Here is the call graph for this function:

◆ setScrollerProperties

void QScroller::setScrollerProperties ( const QScrollerProperties & prop)
slot

Definition at line 319 of file qscroller.cpp.

References d, emit, scrollerPropertiesChanged(), and sp.

+ Here is the call graph for this function:

◆ setSnapPositionsX() [1/2]

void QScroller::setSnapPositionsX ( const QList< qreal > & positions)

Set the snap positions for the horizontal axis to a list of positions.

This overwrites all previously set snap positions and also a previously set snapping interval. Snapping can be deactivated by setting an empty list of positions.

Definition at line 781 of file qscroller.cpp.

References d, and positions.

◆ setSnapPositionsX() [2/2]

void QScroller::setSnapPositionsX ( qreal first,
qreal interval )

Set the snap positions for the horizontal axis to regular spaced intervals.

The first snap position is at first. The next at first + interval. This can be used to implement a list header. This overwrites all previously set snap positions and also a previously set snapping interval. Snapping can be deactivated by setting an interval of 0.0

Definition at line 797 of file qscroller.cpp.

References d.

◆ setSnapPositionsY() [1/2]

void QScroller::setSnapPositionsY ( const QList< qreal > & positions)

Set the snap positions for the vertical axis to a list of positions.

This overwrites all previously set snap positions and also a previously set snapping interval. Snapping can be deactivated by setting an empty list of positions.

Definition at line 812 of file qscroller.cpp.

References d, and positions.

◆ setSnapPositionsY() [2/2]

void QScroller::setSnapPositionsY ( qreal first,
qreal interval )

Set the snap positions for the vertical axis to regular spaced intervals.

The first snap position is at first. The next at first + interval. This overwrites all previously set snap positions and also a previously set snapping interval. Snapping can be deactivated by setting an interval of 0.0

Definition at line 827 of file qscroller.cpp.

References d.

◆ state()

QScroller::State QScroller::state ( ) const

Definition at line 484 of file qscroller.cpp.

References d.

◆ stateChanged

void QScroller::stateChanged ( QScroller::State newState)
signal

QScroller emits this signal whenever the state changes.

newState is the new State.

See also
state

Referenced by QAbstractItemView::viewportEvent().

+ Here is the caller graph for this function:

◆ stop()

void QScroller::stop ( )

Stops the scroller and resets its state back to Inactive.

Definition at line 493 of file qscroller.cpp.

References clampToRect(), d, Qt::Horizontal, Inactive, qIsNaN(), QPointF::setX(), and Qt::Vertical.

Referenced by QFlickGestureRecognizer::recognize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ target()

QObject * QScroller::target ( ) const

Returns the target object of this scroller.

See also
hasScroller(), scroller()

Definition at line 293 of file qscroller.cpp.

References d.

Referenced by grabGesture(), and ungrabGesture().

+ Here is the caller graph for this function:

◆ ungrabGesture()

void QScroller::ungrabGesture ( QObject * target)
static

Ungrabs the gesture for the target.

Does nothing if no gesture is grabbed.

See also
grabGesture(), grabbedGesture()

Definition at line 414 of file qscroller.cpp.

References scroller, sp, target(), QWidget::ungrabGesture(), QGestureRecognizer::unregisterRecognizer(), and widget.

Referenced by grabGesture(), and QPixmapStyle::unpolish().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ velocity()

QPointF QScroller::velocity ( ) const

Returns the current scrolling velocity in meter per second when the state is Scrolling or Dragging.

Returns a zero velocity otherwise.

The velocity is reported for both the x and y axis separately by using a QPointF.

See also
pixelPerMeter()

Definition at line 556 of file qscroller.cpp.

References d, differentialForProgress(), Dragging, now, qSign(), Scrolling, sp, and state.

Referenced by scrollTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QFlickGestureRecognizer

friend class QFlickGestureRecognizer
friend

Definition at line 110 of file qscroller.h.

Referenced by grabGesture().

Property Documentation

◆ scrollerProperties

QScroller::scrollerProperties
readwrite

The scroller properties of this scroller.

The properties are used by the QScroller to determine its scrolling behavior.

Definition at line 29 of file qscroller.h.

Referenced by QFlickGestureRecognizer::recognize().

◆ state

QScroller::state
read

the state of the scroller

See also
QScroller::State

Definition at line 28 of file qscroller.h.

Referenced by QFlickGestureRecognizer::recognize(), and velocity().


The documentation for this class was generated from the following files: