[Qgis-developer] Remove editing functions from QgsVectorLayer

Martin Dobias wonder.sk at gmail.com
Mon Apr 15 23:10:26 PDT 2013


On Tue, Apr 16, 2013 at 12:53 AM, Nathan Woodrow <madmanwoo at gmail.com> wrote:
> What would be the API calls in order to add a new feature to a layer and
> commit the result?

layer.startEditing()
layer.editBuffer().addFeature( feature )
layer.commitChanges()

Anyway if someone wants to add a new feature permanently, it should be
rather done this way:
layer.dataProvider().addFeatures( [feature] )
It's more efficient and it does not mess with the editing state of the
layer (imagine you are editing a layer and a plugin action will commit
all your changes without asking!).

Martin


More information about the Qgis-developer mailing list