QGraphicsSceneEvent

QGraphicsSceneEvent类为所有图形视图相关事件提供基类。


Header:#include <QGraphicsSceneEvent>
CMake:find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake:QT += widgets
Inherits:QEvent
Inherited By:

QGraphicsSceneContextMenuEvent

QGraphicsSceneDragDropEvent

QGraphicsSceneHelpEvent

QGraphicsSceneHoverEvent

QGraphicsSceneMouseEvent

QGraphicsSceneMoveEvent

QGraphicsSceneResizeEvent

QGraphicsSceneWheelEvent


【详细描述】

当一个QGraphicsView对象接收到鼠标、键盘和拖放事件(QMouseEventQKeyEvent, QDragEvent)时,会将这些事件转换为QGraphicsSceneEvent子类的实例,并转发到它显示的 QGraphicsScene实例,然后这个场景将事件转发到相关项目。

例如,当 QGraphicsView接收到MousePress类型的QMouseEvent作为对用户单击的响应时,视图会通过其mousePressEvent ()函数将GraphicsSceneMousePress 类型的 QGraphicsSceneMouseEvent发送到底层QGraphicsScene。默认的 QGraphicsScene::mousePressEvent()实现了确定单击了哪个项目并将事件转发到 QGraphicsItem::mousePressEvent()。

QGraphicsSceneMouseEventQGraphicsSceneContextMenuEvent等子类在屏幕、场景和项目坐标中提供原始QEvent坐标(请参阅 screenPos()、scenePos()和pos())。项目坐标由 QGraphicsScene在将事件转发到QGraphicsItem之前设置。鼠标事件还增加了从视图接收的最后一个事件中检索坐标的可能性(请参阅 lastScreenPos ()、 lastScenePos () 和 lastPos ())。

另请参见 QEvent


【公有函数】

virtual~QGraphicsSceneEvent()销毁事件。
quint64timestamp() const返回原始事件的时间戳,如果原始事件未报告时间戳,则返回 0。
QWidget *widget() const返回事件源自的控件,如果事件源自另一个应用程序,则返回nullptr。

<<< 返回上一级【QEvent类】 

<<< 返回根页面

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值