QScrollEvent Class

在滚动时发送 QScrollEvent 类。更多

头文件: #include <QScrollEvent>
CMake.QScrollEvent find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
继承: QEvent

公共类型

enum ScrollState { ScrollStarted, ScrollUpdated, ScrollFinished }

公共函数

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

详细说明

发送滚动事件是为了指示接收器应被滚动。通常,接收器应是可视化的,如QWidgetQGraphicsObject

需要注意的是,两个来源发送的 QScrollEvents 不能相互冲突。不过,使用QScroller::scrollTo 可以节省时间。

另请参阅 QScrollPrepareEventQScroller

成员类型文档

enum QScrollEvent::ScrollState

该枚举描述了滚动事件可能具有的状态。

常量描述
QScrollEvent::ScrollStarted0为滚动活动的第一个滚动事件设置。
QScrollEvent::ScrollUpdated1为滚动活动中除第一个和最后一个滚动事件外的所有滚动事件设置。
QScrollEvent::ScrollFinished2为滚动活动的最后一个滚动事件设置。

另请参阅 QScrollEvent::scrollState().

成员函数文档

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

创建一个新的 QScrollEventcontentPos 是新的内容位置,overshootDistance 是新的超调距离,而scrollState 则表示该滚动事件是第一个、最后一个还是介于两者之间的某个事件。

QPointF QScrollEvent::contentPos() const

返回新的滚动位置。

QPointF QScrollEvent::overshootDistance() const

返回新的过冲距离。有关超调一词的解释,请参阅QScroller

另请参见 QScroller

QScrollEvent::ScrollState QScrollEvent::scrollState() const

以 ScrollStateFlag 值组合的形式返回当前滚动状态。 ScrollStarted (如果该滚动事件是滚动活动中的第一个(或最后一个)事件,则将设置 ScrollStateFlag(或ScrollFinished )。请注意,如果活动由单个QScrollEvent 组成,则可同时设置这两个值。中间的所有其他滚动事件的状态都将设置为ScrollUpdated

例如,当滚动开始和停止时,部件可以还原选择。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.