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
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.
-
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 (QgsVectorLayer) – The layer to which the feature should be added
defaultValues (Dict[int) – Default values for the feature to add
defaultGeometry (
QgsGeometry
= QgsGeometry()) – A default geometry to add to the featurefeature – Updated feature after adding will be written back to this
- Return type
Tuple[bool, QgsFeature]
- 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 (QgsVectorLayer) – The layer
request (QgsFeatureRequest) – The request for the features to be moved. It will be assigned to a new feature request with the newly copied features.
dx (float = 0) – The translation on x
dy (float = 0) – The translation on y
errorMsg – If given, it will contain the error message
- Return type
Tuple[bool,
QgsFeatureRequest
, str]- 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 (QgsVectorLayer) – The layer to commit
- Return type
bool
- 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 (QgsVectorLayer) – The layer on which to start an edit session
- Return type
bool
- 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 (QgsVectorLayer) – The layer to commit
allowCancel (bool = True) – True if a cancel button should be offered
- Return type
bool
- Returns
True if successful
TODO QGIS 3: remove const qualifier
-
timerEvent
()¶
-