Class: QgsVectorLayerEditBufferGroup

The edit buffer group manages a group of edit buffers.

Commands like commit and rollback are managed by the group invokes individual addFeature(), deleteFeature(), … in the correct order across all contained edit buffers.

Added in version 3.26.

Class Hierarchy

Inheritance diagram of qgis.core.QgsVectorLayerEditBufferGroup

Base classes

QObject

class qgis.core.QgsVectorLayerEditBufferGroup[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsEditBufferGroup

Parameters:

parent (Optional[QObject] = None)

addLayer(self, layer: QgsVectorLayer | None)[source]

Add a layer to this edit buffer group.

Parameters:

layer (Optional[QgsVectorLayer])

clear(self)[source]

Remove all layers from this edit buffer group.

commitChanges(self, stopEditing: bool = True)[source]

Attempts to commit any changes to disk. Returns the result of the attempt. If a commit fails, the in-memory changes are left alone.

This allows editing to continue if the commit failed on e.g. a disallowed value in a Postgres database - the user can re-edit and try again.

The commits occur in distinct stages, (add attributes, add features, change attribute values, change geometries, delete features, delete attributes) so if a stage fails, it’s difficult to roll back cleanly. Therefore any error message also includes which stage failed so that the user has some chance of repairing the damage cleanly.

Parameters:

stopEditing (bool = True) -> (bool) – if set to False, the layer will stay in editing mode. Otherwise the layer editing mode will be disabled if the commit is successful.

Returns:

  • True on success

  • commitErrors: a list of descriptive errors if the commit fails.

isEditing(self) bool[source]

Returns True if the layers are in editing mode

Return type:

bool

layers(self) Set[QgsVectorLayer]

Gets the set of layers currently managed by this edit buffer group.

Return type:

Set[QgsVectorLayer]

Returns:

Layer set

modifiedLayers(self) Set[QgsVectorLayer]

Gets the set of modified layers currently managed by this edit buffer group.

Return type:

Set[QgsVectorLayer]

Returns:

Layer set

removeLayer(self, layer: QgsVectorLayer | None)[source]

Remove a layer from this edit buffer group.

Added in version 3.42.

Parameters:

layer (Optional[QgsVectorLayer])

rollBack(self, stopEditing: bool = True)[source]

Stop editing and discard the edits

Parameters:

stopEditing (bool = True) -> (bool) – if set to False, the layer will stay in editing mode. Otherwise the layer editing mode will be disabled if the rollback is successful.

Returns:

  • False if errors occurred during rollback

  • rollbackErrors: a list of descriptive errors if the rollback fails.

startEditing(self) bool[source]

Start editing

Return type:

bool

Returns:

True on success