Class: QgsSnapToGridCanvasItem

class qgis.gui.QgsSnapToGridCanvasItem(mapCanvas: QgsMapCanvas)

Bases: QgsMapCanvasItem

Will automatically be added to the mapCanvas.

Shows a grid on the map canvas given a spatial resolution.

New in version 3.4.

Parameters

mapCanvas

contextMenuEvent(self, QGraphicsSceneContextMenuEvent)
crs(self)QgsCoordinateReferenceSystem

The CRS in which the grid should be calculated. By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.

Return type

QgsCoordinateReferenceSystem

dragEnterEvent(self, QGraphicsSceneDragDropEvent)
dragLeaveEvent(self, QGraphicsSceneDragDropEvent)
dragMoveEvent(self, QGraphicsSceneDragDropEvent)
dropEvent(self, QGraphicsSceneDragDropEvent)
enabled(self) → bool

Enable this item. It will be hidden if disabled.

Return type

bool

focusInEvent(self, QFocusEvent)
focusOutEvent(self, QFocusEvent)
hoverEnterEvent(self, QGraphicsSceneHoverEvent)
hoverLeaveEvent(self, QGraphicsSceneHoverEvent)
hoverMoveEvent(self, QGraphicsSceneHoverEvent)
inputMethodEvent(self, QInputMethodEvent)
inputMethodQuery(self, Qt.InputMethodQuery) → Any
itemChange(self, QGraphicsItem.GraphicsItemChange, Any) → Any
keyPressEvent(self, QKeyEvent)
keyReleaseEvent(self, QKeyEvent)
mouseDoubleClickEvent(self, QGraphicsSceneMouseEvent)
mouseMoveEvent(self, QGraphicsSceneMouseEvent)
mousePressEvent(self, QGraphicsSceneMouseEvent)
mouseReleaseEvent(self, QGraphicsSceneMouseEvent)
paint(self, painter: QPainter)
Parameters

painter (QPainter) –

point(self)QgsPointXY

A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.

Return type

QgsPointXY

precision(self) → float

The resolution of the grid in map units. If a crs has been specified it will be in CRS units.

Return type

float

prepareGeometryChange(self)
sceneEvent(self, QEvent) → bool
sceneEventFilter(self, QGraphicsItem, QEvent) → bool
setCrs(self, crs: QgsCoordinateReferenceSystem)

The CRS in which the grid should be calculated. By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.

Parameters

crs (QgsCoordinateReferenceSystem) –

setEnabled(self, enabled: bool)

Enable this item. It will be hidden if disabled.

Parameters

enabled (bool) –

setPoint(self, point: QgsPointXY)

A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.

Parameters

point (QgsPointXY) –

setPrecision(self, precision: float)

The resolution of the grid in map units. If a crs has been specified it will be in CRS units.

Parameters

precision (float) –

setRenderContextVariables(self, p: QPainter, context: QgsRenderContext) → bool

Sets render context parameters

Parameters
  • p – painter for rendering

  • context – out: configured context

Returns

True in case of success

updateCanvas(self)

schedules map canvas for repaint

updateMicroFocus(self)
wheelEvent(self, QGraphicsSceneWheelEvent)