- Qt 6.6
- Qt GUI
- C++ Classes
- QScrollEvent
- Qt 6.6.2 Reference Documentation

# QScrollEvent Class

The QScrollEvent class is sent when scrolling. More...

Header: | #include <QScrollEvent>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: | QT += gui
Inherits: | QEvent

- List of all members, including inherited members
- QScrollEvent is part of Event Classes.

## Public Types

enum | ScrollState { ScrollStarted, ScrollUpdated, ScrollFinished }

## Public Functions

| QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, QScrollEvent::ScrollState scrollState)
QPointF | contentPos() const
QPointF | overshootDistance() const
QScrollEvent::ScrollState | scrollState() const

## Detailed Description

The scroll event is sent to indicate that the receiver should be scrolled. Usually the receiver should be something visual like QWidget or QGraphicsObject.

Some care should be taken that no conflicting QScrollEvents are sent from two sources. Using QScroller::scrollTo is save however.

See also QScrollPrepareEvent and QScroller.

## Member Type Documentation

### enum QScrollEvent::ScrollState

This enum describes the states a scroll event can have.

Constant | Value | Description
--- | --- | ---
`QScrollEvent::ScrollStarted` | `0` | Set for the first scroll event of a scroll activity.
`QScrollEvent::ScrollUpdated` | `1` | Set for all but the first and the last scroll event of a scroll activity.
`QScrollEvent::ScrollFinished` | `2` | Set for the last scroll event of a scroll activity.

See also QScrollEvent::scrollState().

## Member Function Documentation

### QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, QScrollEvent::ScrollState scrollState)

Creates a new QScrollEvent contentPos is the new content position, overshootDistance is the new overshoot distance while scrollState indicates if this scroll event is the first one, the last one or some event in between.

### QPointF QScrollEvent::contentPos() const

Returns the new scroll position.

### QPointF QScrollEvent::overshootDistance() const

Returns the new overshoot distance. See QScroller for an explanation of the term overshoot.

See also QScroller.

### QScrollEvent::ScrollState QScrollEvent::scrollState() const

Returns the current scroll state as a combination of ScrollStateFlag values. ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity. Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent. All other scroll events in between will have their state set to ScrollUpdated.

A widget could for example revert selections when scrolling is started and stopped.