Class: QgsVectorLayerTools¶
-
class
qgis.core.
QgsVectorLayerTools
¶ Bases:
PyQt5.QtCore.QObject
Methods in this class are used to handle basic operations on vector layers. With an implementation of this class, parts of the application can ask for an operation to be done and the implementation will then take care of it.
Reimplement this class, if you need to have custom checks or GUI elements in your application.
Enums
Methods
This method should/will be called, whenever a new feature will be added to the layer
Copy and move features with defined translation.
Should be called, when the features should be committed but the editing session is not ended.
This will be called, whenever a vector layer should be switched to edit mode.
Will be called, when an editing session is ended and the features should be committed.
Signals
Attributes
-
addFeature
(self, layer: QgsVectorLayer, defaultValues: Dict[int, Any] = {}, defaultGeometry: QgsGeometry = QgsGeometry()) → Tuple[bool, QgsFeature]¶ This method should/will be called, whenever a new feature will be added to the layer
- Parameters
layer – The layer to which the feature should be added
defaultValues – Default values for the feature to add
defaultGeometry – A default geometry to add to the feature
- Returns
True in case of success, False if the operation failed/was aborted
feature: Updated feature after adding will be written back to this
-
childEvent
()¶
-
connectNotify
()¶
-
copyMoveFeatures
(self, layer: QgsVectorLayer, request: QgsFeatureRequest, dx: float = 0, dy: float = 0) → Tuple[bool, QgsFeatureRequest, str]¶ Copy and move features with defined translation.
- Parameters
layer – The layer
request – The request for the features to be moved. It will be assigned to a new feature request with the newly copied features.
dx – The translation on x
dy – The translation on y
- Returns
True if all features could be copied.
errorMsg: If given, it will contain the error message
-
customEvent
()¶
-
disconnectNotify
()¶
-
isSignalConnected
()¶
-
receivers
()¶
-
saveEdits
(self, layer: QgsVectorLayer) → bool¶ Should be called, when the features should be committed but the editing session is not ended.
- Parameters
layer – The layer to commit
- Returns
True if successful
-
sender
()¶
-
senderSignalIndex
()¶
-
startEditing
(self, layer: QgsVectorLayer) → bool¶ This will be called, whenever a vector layer should be switched to edit mode. Check the providers capability to edit in here. If successful layer->startEditing() will be called and true returned.
- Parameters
layer – The layer on which to start an edit session
- Returns
True, if the editing session was started
-
stopEditing
(self, layer: QgsVectorLayer, allowCancel: bool = True) → bool¶ Will be called, when an editing session is ended and the features should be committed. Appropriate dialogs should be shown like
- Parameters
layer – The layer to commit
allowCancel – True if a cancel button should be offered
- Returns
True if successful
-
timerEvent
()¶
-