Class: QgsMapToolExtent

A map tool that emits an extent from a rectangle drawn onto the map canvas.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsMapToolExtent

Base classes

QgsMapTool

Abstract base class for all map tools. Map tools are user interactive tools for manipulating the map canvas. For example map pan and zoom features are implemented as map tools.

QObject

Methods

clearRubberBand

Removes the tool's rubber band from the canvas.

extent

Returns the current extent drawn onto the canvas.

ratio

Returns the current fixed aspect ratio to be used when dragging extent onto the canvas.

setRatio

Sets a fixed aspect ratio to be used when dragging extent onto the canvas.

Signals

extentChanged

signal emitted on extent change

class qgis.gui.QgsMapToolExtent[source]

Bases: QgsMapTool

__init__(canvas: QgsMapCanvas | None)

constructor

Parameters:

canvas (Optional[QgsMapCanvas])

clearRubberBand(self)[source]

Removes the tool’s rubber band from the canvas.

Added in version 3.20.

extent(self) QgsRectangle[source]

Returns the current extent drawn onto the canvas.

Return type:

QgsRectangle

signal extentChanged(extent: QgsRectangle)[source]

signal emitted on extent change

Parameters:

extent (QgsRectangle)

ratio(self) QSize[source]

Returns the current fixed aspect ratio to be used when dragging extent onto the canvas. If the aspect ratio isn’t fixed, the width and height will be set to zero.

Return type:

QSize

setRatio(self, ratio: QSize)[source]

Sets a fixed aspect ratio to be used when dragging extent onto the canvas. To unset a fixed aspect ratio, set the width and height to zero.

Parameters:

ratio (QSize) – aspect ratio’s width and height