QScrollEvent Class
在滚动时会发送 QScrollEvent 类事件。更多内容...
| 头文件: | #include <QScrollEvent> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
| 继承自: | QEvent |
- 所有成员的列表,包括继承的成员
- QScrollEvent 属于事件类。
公共类型
| 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 |
受保护函数
| QScrollEvent(QScrollEvent &&) | |
| QScrollEvent & | operator=(QScrollEvent &&) |
| QScrollEvent & | operator=(const QScrollEvent &other) |
详细说明
发送滚动事件是为了指示接收者应进行滚动。通常,接收者应为某种可视对象,例如QWidget 或QGraphicsObject 。
应注意避免两个来源发送相互冲突的 QScrollEvents。不过,使用QScroller::scrollTo 是安全的。
另请参阅 QScrollPrepareEvent 和QScroller 。
成员类型文档
enum QScrollEvent::ScrollState
此枚举描述了滚动事件可能处于的状态。
| 常量 | 值 | 描述 |
|---|---|---|
QScrollEvent::ScrollStarted | 0 | 用于滚动活动的第一个滚动事件。 |
QScrollEvent::ScrollUpdated | 1 | 用于滚动操作中除第一个和最后一个滚动事件以外的所有滚动事件。 |
QScrollEvent::ScrollFinished | 2 | 用于设置滚动活动的最后一个滚动事件。 |
另请参阅 ` QScrollEvent::scrollState()`。
成员函数文档
QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, QScrollEvent::ScrollState scrollState)
创建一个新的 QScrollEvent 对象。contentPos 表示新内容的位置,overshootDistance 表示新的超距,而scrollState 则指示该滚动事件是第一个、最后一个还是中间的某个事件。
[protected delete] QScrollEvent::QScrollEvent(QScrollEvent &&)
通过移动构造一个QScrollEvent 的实例。该函数已被删除。
QPointF QScrollEvent::contentPos() const
返回新的滚动位置。
QPointF QScrollEvent::overshootDistance() const
返回新的超调距离。关于“超调”这一术语的解释,请参见QScroller 。
另请参阅 QScroller 。
QScrollEvent::ScrollState QScrollEvent::scrollState() const
返回当前滚动状态,该状态由一组 ScrollStateFlag 值组合而成。如果此滚动事件是滚动操作中的第一个(或最后一个)事件,则会设置ScrollStarted (或ScrollFinished )。 请注意,如果该操作由单个QScrollEvent 组成,则这两个值可以同时被设置。其间的所有其他滚动事件的状态都将被设置为ScrollUpdated 。
例如,小部件可以在滚动开始和停止时恢复选中状态。
[protected delete] QScrollEvent &QScrollEvent::operator=(QScrollEvent &&)
将other 通过移动赋值操作赋值给此QScrollEvent 实例。该函数已被删除。
[noexcept protected default] QScrollEvent &QScrollEvent::operator=(const QScrollEvent &other)
将other 复制并赋值给此QScrollEvent 实例。
© 2026 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.