3

Set a layer editable through the Python console works fine here (QGIS 2.18.4):

layer=iface.activeLayer()
if not layer.isEditable():
    qgis.utils.iface.actionToggleEditing().trigger()

But I do not know how to set a input layer editable in a QGIS processing script:

##Input_layer=vector
# ...
inlayer = processing.getObject(Input_layer)
if not inlayer.isEditable():
    #???

Can anybody help me with this?

4
+50

You can use QgsVectorLayer.startEditing().
Then once your edits are complete you can either commitChanges() or rollBack() as approriate

##Input_layer=vector
# ...
inlayer = processing.getObject(Input_layer)
if not inlayer.isEditable():
    inlayer.startEditing()
    # ...
    inlayer.commitChanges()
  • inlayer.startEditing() works fine, I just have to wait 22 hours to a award the bounty. – eclipsed_by_the_moon Mar 15 '17 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.