[Qgis-developer] add toogle editing into custom form

Luca Lanteri lklanteri at gmail.com
Mon Feb 16 14:38:37 PST 2015


Hi,
excuse me for the very very newby question.

I want to add a button in my custom form in order to toogle the editing
status of a layer. I try to navigate the qgis api but I can't understand
the way to stop editing and save/reject modify. I try to insert a code like
this [0] (obviously the else part doesn't fit my request, it's just a
pleaceholder to try my code).

[0]
def toggleEdit():
        aLayer = QgsMapLayerRegistry.instance().mapLayersByName('layer')[0]
        if not aLayer.isEditable():
                aLayer.startEditing()
        else:
                aLayer.rollBack(True)

any hint ?
thanks in advance

Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150216/51f8790a/attachment.html>


More information about the Qgis-developer mailing list