Class: QgsPlotMouseEvent

A mouse event which is the result of a user interaction with a QgsPlotCanvas.

The event is sent whenever the user moves, clicks, releases or double clicks the mouse.

In addition to the coordinates in pixel space the event may have knowledge about geographic coordinates corresponding to the event.

Added in version 3.26.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsPlotMouseEvent

Base classes

QMouseEvent

QInputEvent

QEvent

Methods

isSnapped

Returns True if the point can be snapped to the plot.

mapPoint

Returns the point in map coordinates corresponding to the event.

snappedPoint

Returns the point snapped to the plot, if possible.

class qgis.gui.QgsPlotMouseEvent[source]

Bases: QMouseEvent

__init__(canvas: QgsPlotCanvas | None, event: QMouseEvent | None)

Creates a new QgsPlotMouseEvent.

Parameters:
  • canvas (Optional[QgsPlotCanvas]) – The map canvas on which the event occurred

  • event (Optional[QMouseEvent]) – The original mouse event

__init__(canvas: QgsPlotCanvas | None, type: QEvent.Type, pos: QPoint, button: Qt.MouseButton = Qt.NoButton, buttons: Qt.MouseButtons | Qt.MouseButton = Qt.NoButton, modifiers: Qt.KeyboardModifiers | Qt.KeyboardModifier = Qt.NoModifier)

Creates a new QgsPlotMouseEvent.

Parameters:
  • canvas (Optional[QgsPlotCanvas]) – The canvas on which the event occurred

  • type (QEvent.Type) – The type of the event

  • pos (QPoint) – The pixel position of the mouse

  • button (Qt.MouseButton = Qt.NoButton) – The pressed button

  • buttons (Union[Qt.MouseButtons, Qt.MouseButton] = Qt.NoButton) – Further buttons that are pressed

  • modifiers (Union[Qt.KeyboardModifiers, Qt.KeyboardModifier] = Qt.NoModifier) – Keyboard modifiers

__init__(a0: QgsPlotMouseEvent)
Parameters:

a0 (QgsPlotMouseEvent)

isSnapped(self) bool[source]

Returns True if the point can be snapped to the plot.

Return type:

bool

mapPoint(self) QgsPoint[source]

Returns the point in map coordinates corresponding to the event.

May return an empty point if the event cannot be converted to a map point.

Return type:

QgsPoint

snappedPoint(self) QgsPointXY[source]

Returns the point snapped to the plot, if possible.

Returns the original canvas point if snapping was not possible.

Return type:

QgsPointXY