QGraphicsSceneEvent

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

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类】 

<<< 返回根页面

QT开发教程】图像场景中上下文菜单事件管理QGraphicsSceneContextMenuEvent类详解及实战应用 本文详细介绍了QGraphicsSceneContextMenuEvent类的基本用法与高级应用技巧,通过实例代码展示了如何在QGraphicsScene中处理右键上下文菜单事件。通过合理使用QGraphicsSceneContextMenuEvent,可以显著提升应用的右键菜单交互性能,实现更多丰富的用户操作。希望本文能为您在Qt开发中的上下文菜单事件管理提供实用帮助。 阅读详情

相关推荐

QT开发教程】场景鼠标释放事件管理QGraphicsSceneMouseReleaseEvent类详解及实战应用

本文详细介绍了QGraphicsSceneMouseReleaseEvent类的基本用法与高级应用技巧,通过实例代码展示了如何在QGraphicsScene中处理鼠标释放事件。通过合理使用QGraphicsSceneMouseReleaseEvent,可以显著提升应用的鼠标交互性能,实现丰富的用户操作。希望本文能为您在Qt开发中的鼠标释放事件管理提供实用帮助。

科技改变人类,技术成就未来 591

Qt图形视图框架:QGraphicsScene详解

一、描述 1、场景提供了一个用于管理大量2D图形项的平面。该类充当图形项的容器。 它与视图一起用于可视化2D曲面上的图形图形项。 2、场景没有自己的视觉外观,只负责管理图形项。 3、场景的最大优势之一就是其快速有效地定位图形项的能力。即使场景中有数百万个图形项。 4、场景的另一个职责是传播来自视图的事件。要将事件发送到场景,可以构造一个继承QEvent的事件,然后使用QApplication::sendEvent()将其发送。event()负责将事件调度到各个图形项。 二、类型成员 1、QGra

友善啊,朋友的博客 3万+

QT开发教程】场景拖动移动事件管理QGraphicsSceneDragMoveEvent类详解及实战应用

本文详细介绍了QGraphicsSceneDragMoveEvent类的基本用法与高级应用技巧,通过实例代码展示了如何在QGraphicsScene中处理拖动移动事件。通过合理使用QGraphicsSceneDragMoveEvent,可以显著提升应用的拖动交互性能,实现更丰富的用户操作。希望本文能为您在Qt开发中的拖动移动事件管理提供实用帮助。

科技改变人类,技术成就未来 846

QGraphicsView,QGraphicsScene和QGraphicsItem

图形视图框架提供了一个基于图形项的模型视图编程方法,主要由场景、视图和图形项三部分组成,这三部分分别由QGraphicsScene、QGraphicsView和QGraphicsItem这三个类来表示。

weixin_43956958的博客 6103

QGraphics 简单的案例

QGraphics 主要有三部分组成场景(QGraphicsScene)、视图(QGraphicsView)、图元(QGraphicsItem)组成: 下面是简单的一个QGraphics案例 每次随机产生五中不同的颜色的图元,+放大、-缩小、→旋转、(控制所有的图元)。控制某一个图元。↓向下移动10,悬停提示。鼠标点击光标变化。右键回到中心 代码 myitem.h #include <QGr...

weixin_42692504的博客 928

QGraphicsSceneEvent Class

Header:#include < QGraphicsSceneEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QEvent Inherited By:QGraphicsSceneContextMenuEvent, QGraphicsSceneDragDropEvent, QGraphicsSceneHelpEvent, QGraphicsSceneHoverEvent, QGraphicsSceneMouseEvent, QGraphicsSceneM

weixin_43446462的博客 310

QGraphicsSceneContextMenuEvent Class

Header:#include < QGraphicsSceneContextMenuEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.2.

weixin_43446462的博客 344

QGraphicsSceneWheelEvent Class

Header:#include < QGraphicsSceneWheelEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.2.

weixin_43446462的博客 220

QGraphicsSceneDragDropEvent Class

Header:#include < QGraphicsSceneDragDropEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.2.

weixin_43446462的博客 401

QGraphicsSceneResizeEvent Class

Header:#include < QGraphicsSceneResizeEvent > qmake:QT += widgets Since:Qt 4.4 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.4.

weixin_43446462的博客 245

QGraphicsSceneHoverEvent Class

Header:#include < QGraphicsSceneHoverEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.2.

weixin_43446462的博客 245

QGraphicsSceneMoveEvent Class

Header:#include < QGraphicsSceneMoveEvent > qmake:QT += widgets Since:Qt 4.4 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.4.

weixin_43446462的博客 207

QGraphicsSceneHelpEvent Class

Header:#include < QGraphicsSceneHelpEvent > qmake:QT += widgets Since:Qt 4.2 Inherits:QGraphicsSceneEvent This class was introduced in Qt 4.2.

weixin_43446462的博客 328

QT 的 Graphics View 系统

这个框架是一个相对成熟的渲染引擎的上层框架,通常也可以会叫做 Scene - View。 在QT中,GraphicsView是一个与QWdiget系列一点点不一样的系统。这个系统主要由下面几个框架类构成:QGraphicsView,  QGraphicsScene, QGraphicsItem   QGrahpicsView是从原生的QWidget继承过来,QGraphi

imxiangzi的专栏 1296

Qt图形视图框架:QGraphicsScene事件传播与交互机制解析

本文深入解析Qt图形视图框架中QGraphicsScene的事件传播与交互机制,详细介绍了事件分发流程、坐标转换技巧以及BSP树索引优化策略。通过实战代码示例展示如何实现自定义图形项交互,帮助开发者高效构建复杂的图形界面应用。

metaverse5vr的博客 114

QGraphcisView 官方文档翻译

QGraphicsView 官方文档翻译

幻酌大大 368
上一篇: QList类
下一篇: QTreeWidgetItem类
floatbit
博客等级 码龄24年 460粉丝 47原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值