Class: QgsLayoutViewMouseEvent

A QgsLayoutViewMouseEvent is the result of a user interaction with the mouse on a QgsLayoutView.

It is sent whenever the user moves, clicks, releases or double clicks the mouse. In addition to the coordinates in pixel space it also knows the coordinates the layout space.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutViewMouseEvent

Base classes

QMouseEvent

QInputEvent

QEvent

Methods

isSnapped

Returns True if point was snapped, e.g. to grid or guide lines.

layoutPoint

Returns the event point location in layout coordinates.

snapPoint

Manually triggers a snap for the mouse event position using the layout's snapper.

snappedPoint

Returns the snapped event point location in layout coordinates.

class qgis.gui.QgsLayoutViewMouseEvent[source]

Bases: QMouseEvent

__init__(view: QgsLayoutView | None, event: QMouseEvent | None, snap: bool = False)

Constructor for QgsLayoutViewMouseEvent. Should only be required to be called from the QgsLayoutView.

Parameters:
  • view (Optional[QgsLayoutView]) – The view in which the event occurred.

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

  • snap (bool = False) – set to True to snap the point using the layout’s snapping settings

__init__(a0: QgsLayoutViewMouseEvent)
Parameters:

a0 (QgsLayoutViewMouseEvent)

isSnapped(self) bool[source]

Returns True if point was snapped, e.g. to grid or guide lines.

See also

snappedPoint()

Return type:

bool

layoutPoint(self) QPointF[source]

Returns the event point location in layout coordinates.

Return type:

QPointF

snapPoint(self, horizontalSnapLine: QGraphicsLineItem | None = None, verticalSnapLine: QGraphicsLineItem | None = None, ignoreItems: Iterable[QgsLayoutItem] = [])[source]

Manually triggers a snap for the mouse event position using the layout’s snapper.

If the horizontalSnapLine and verticalSnapLine arguments are specified, then the snapper will automatically display and position these lines to indicate snapping positions to item bounds.

The ignoreItems argument can be used to specify a list of items to avoid snapping to.

Parameters:
  • horizontalSnapLine (Optional[QGraphicsLineItem] = None)

  • verticalSnapLine (Optional[QGraphicsLineItem] = None)

  • ignoreItems (Iterable[QgsLayoutItem] = [])

snappedPoint(self) QPointF[source]

Returns the snapped event point location in layout coordinates. The snapped point will consider all possible snapping methods, such as snapping to grid or guide lines.

See also

isSnapped()

Return type:

QPointF