[Qgis-developer] add toogle editing into custom form

Martin Dobias wonder.sk at gmail.com
Sat Feb 21 23:56:01 PST 2015


Hi Luca

aLayer.rollBack() stops the editing and rejects the changes. There is also
aLayer.commitChanges() that stops the editing and saves all changes -
that's probably what you were looking for.

Cheers
Martin


On Tue, Feb 17, 2015 at 5:38 AM, Luca Lanteri <lklanteri at gmail.com> wrote:

> 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
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150222/ad5e710f/attachment.html>


More information about the Qgis-developer mailing list