Class: QgsMapToolEdit

Base class for map tools that edit vector geometry.

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis.gui.QgsMapToolEdit

Base classes

QgsMapTool

Abstract base class for all map tools.

QObject

Subclasses

QgsMapToolAdvancedDigitizing

A QgsMapTool which gives events directly in map coordinates and allows filtering of events.

Enums

TopologicalResult

Methods

addTopologicalPoints

Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons.

createGeometryRubberBand

Creates a geometry rubber band with the color/line width from the QGIS settings.

createRubberBand

Creates a rubber band with the color/line width respecting the user's settings.

createRubberBandForLayer

Creates and prepares a rubber band for a layer and optional set of feature IDs.

currentVectorLayer

Returns the current vector layer for the map canvas or None if none is set.

notifyNotEditableLayer

Display a timed message bar noting the active vector layer is not editable.

notifyNotVectorLayer

Display a timed message bar noting the active layer is not vector.

prepareRubberBandForLayer

Configures a rubberBand for a specific layer and optional list of feature IDs.

Static Methods

defaultMValue

Returns default M value.

defaultZValue

Returns default Z value.

digitizingFillColor

Returns fill color for rubber bands (from global settings)

digitizingStrokeColor

Returns stroke color for rubber bands (from global settings)

digitizingStrokeWidth

Returns stroke width for rubber bands (from global settings)

class qgis.gui.QgsMapToolEdit[source]

Bases: QgsMapTool

InvalidCanvas = 1
InvalidLayer = 2
Success = 0
class TopologicalResult(*values)

Bases: IntEnum

InvalidCanvas = 1
InvalidLayer = 2
Success = 0
addTopologicalPoints(self, vertices: Iterable[QgsPointXY]) QgsMapToolEdit.TopologicalResult[source]

Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons. The vertices list specifies a set of topological points to add, in the layer’s coordinate reference system.

Deprecated since version 3.12: Will be removed in QGIS 5.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

addTopologicalPoints(self, vertices: Iterable[QgsPoint]) -> QgsMapToolEdit.TopologicalResult Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons. The vertices list specifies a set of topological points to add, in the layer’s coordinate reference system.

Added in version 3.10.

Parameters:

vertices (Iterable[QgsPointXY])

Return type:

QgsMapToolEdit.TopologicalResult

createGeometryRubberBand(self, geometryType: Qgis.GeometryType = Qgis.GeometryType.Line, alternativeBand: bool = False) QgsGeometryRubberBand | None[source]

Creates a geometry rubber band with the color/line width from the QGIS settings. The caller takes ownership of the returned object

Parameters:
  • geometryType (Qgis.GeometryType = Qgis.GeometryType.Line)

  • alternativeBand (bool = False) – if True, rubber band will be set with more transparency and a dash pattern. default is False.

Return type:

Optional[QgsGeometryRubberBand]

createRubberBand(self, geometryType: Qgis.GeometryType = Qgis.GeometryType.Line, alternativeBand: bool = False) QgsRubberBand | None[source]

Creates a rubber band with the color/line width respecting the user’s settings.

The caller takes ownership of the returned object.

Parameters:
  • geometryType (Qgis.GeometryType = Qgis.GeometryType.Line)

  • alternativeBand (bool = False) – if True, the rubber band will be set to have an alternate appearance, with higher transparency and a dashed line style

Return type:

Optional[QgsRubberBand]

createRubberBandForLayer(self, layer: QgsVectorLayer | None = None, fids: Iterable[int] = [], alternativeBand: bool = False) QgsRubberBand | None[source]

Creates and prepares a rubber band for a layer and optional set of feature IDs.

Applies the default digitizing styling, attaches appropriate layer/feature preview items, and shows the rubber band.

The caller takes ownership of the returned object.

Parameters:
  • layer (Optional[QgsVectorLayer] = None) – vector layer containing configuration (defaults to currentVectorLayer())

  • fids (Iterable[int] = []) – IDs of feature being manipulated (optional)

  • alternativeBand (bool = False) – if True, the rubber band will be set to have an alternate appearance, with higher transparency and a dashed line style

Added in version 4.4.

Return type:

Optional[QgsRubberBand]

currentVectorLayer(self) QgsVectorLayer | None[source]

Returns the current vector layer for the map canvas or None if none is set.

Return type:

Optional[QgsVectorLayer]

static defaultMValue() float[source]

Returns default M value. Used for setting M coordinate to new vertex.

Added in version 3.20.

Return type:

float

static defaultZValue() float[source]

Returns default Z value. Used for setting Z coordinate to new vertex.

Return type:

float

static digitizingFillColor() QColor[source]

Returns fill color for rubber bands (from global settings)

Return type:

QColor

static digitizingStrokeColor() QColor[source]

Returns stroke color for rubber bands (from global settings)

Return type:

QColor

static digitizingStrokeWidth() int[source]

Returns stroke width for rubber bands (from global settings)

Return type:

int

notifyNotEditableLayer(self)[source]

Display a timed message bar noting the active vector layer is not editable.

notifyNotVectorLayer(self)[source]

Display a timed message bar noting the active layer is not vector.

prepareRubberBandForLayer(self, rubberBand: QgsRubberBand | None, layer: QgsVectorLayer | None = None, fids: Iterable[int] = [])[source]

Configures a rubberBand for a specific layer and optional list of feature IDs.

Automatically attaches layer-level preview items (such as feature label previews if labeling is enabled and a valid feature is supplied).

Parameters:

Added in version 4.4.