QScrollEvent Class

The QScrollEvent class is sent when scrolling. 更多...

头文件: #include <QScrollEvent>
qmake: QT += gui
开始支持版本: Qt 4.8
基类: QEvent

公有类型

enum ScrollState { ScrollStarted, ScrollUpdated, ScrollFinished }

公有函数

QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
~QScrollEvent()
QPointF contentPos() const
QPointF overshootDistance() const
ScrollState scrollState() const
  • 6 个公有函数继承自 QEvent

其他继承的成员

  • 1 个属性继承自 QEvent
  • 1 个静态公有成员继承自 QEvent
  • 2 个受保护的变量继承自 QEvent

详细描述

The QScrollEvent class is sent when scrolling.

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.

参见 QScrollPrepareEvent and QScroller.

成员类型

enum QScrollEvent::ScrollState

This enum describes the states a scroll event can have.

ConstantValueDescription
QScrollEvent::ScrollStarted0Set for the first scroll event of a scroll activity.
QScrollEvent::ScrollUpdated1Set for all but the first and the last scroll event of a scroll activity.
QScrollEvent::ScrollFinished2Set for the last scroll event of a scroll activity.

参见 QScrollEvent::scrollState().

成员函数

QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, 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.

QScrollEvent::~QScrollEvent()

Destroys QScrollEvent.

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.

参见 QScroller.

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.