PySide6.QtWidgets.QGraphicsSceneEvent¶
- class QGraphicsSceneEvent¶
QGraphicsSceneEvent
类为所有与图形视图相关的事件提供了一个基类。更多…继承自:
QGraphicsSceneWheelEvent
,QGraphicsSceneResizeEvent
,QGraphicsSceneMoveEvent
,QGraphicsSceneMouseEvent
,QGraphicsSceneHoverEvent
,QGraphicsSceneHelpEvent
,QGraphicsSceneDragDropEvent
,QGraphicsSceneContextMenuEvent
概要¶
方法¶
def
__init__()
def
setTimestamp()
def
timestamp()
def
widget()
注意
本文档可能包含从C++自动翻译到Python的代码片段。我们始终欢迎对代码片段翻译的贡献。如果您发现翻译问题,您也可以通过在我们的https:/bugreports.qt.io/projects/PYSIDE上创建工单来告知我们。
详细描述¶
当
QGraphicsView
接收到Qt的鼠标、键盘和拖放事件(QMouseEvent、QKeyEvent、QDragEvent等)时,它会将它们转换为QGraphicsSceneEvent
子类的实例,并将它们转发给其显示的QGraphicsScene
。然后,场景将这些事件转发给相关的项目。例如,当
QGraphicsView
接收到类型为MousePress的QMouseEvent作为用户点击的响应时,视图会通过其mousePressEvent()
函数向底层的QGraphicsScene
发送一个类型为GraphicsSceneMousePress的QGraphicsSceneMouseEvent
。默认的mousePressEvent()
实现会确定哪个项目被点击,并将事件转发给mousePressEvent()
。子类如
QGraphicsSceneMouseEvent
和QGraphicsSceneContextMenuEvent
提供了来自原始 QEvent 的屏幕、场景和项目坐标(参见screenPos()
、scenePos()
和pos()
)。项目坐标由QGraphicsScene
在将事件转发给QGraphicsItem
之前设置。鼠标事件还增加了从视图接收的最后一个事件中检索坐标的可能性(参见lastScreenPos()
、lastScenePos()
和lastPos()
)。另请参阅
- setTimestamp(ts)¶
- Parameters:
ts – 整数
- timestamp()¶
- Return type:
整数
返回原始事件的时间戳,如果原始事件没有报告时间戳,则返回0。
返回事件起源的小部件,如果事件来自另一个应用程序,则返回
None
。