Subgroup: Vector
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.
Methods
addFeature
This method should/will be called, whenever a new feature will be added to the layer childEvent
connectNotify
copyMoveFeatures
Copy and move features with defined translation. customEvent
disconnectNotify
isSignalConnected
receivers
saveEdits
Should be called, when the features should be committed but the editing session is not ended. sender
senderSignalIndex
startEditing
This will be called, whenever a vector layer should be switched to edit mode. stopEditing
Will be called, when an editing session is ended and the features should be committed. timerEvent
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
- feature – Updated feature after adding will be written back to this
Returns: True in case of success, False if the operation failed/was aborted
TODO QGIS 3: remove const qualifier
-
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
- errorMsg – If given, it will contain the error message
Returns: True if all features could be copied.
TODO QGIS 3: remove const qualifier
-
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 TODO QGIS 3: remove const qualifier
-
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 TODO QGIS 3: remove const qualifier
-
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
TODO QGIS 3: remove const qualifier
-
timerEvent
()¶
-