<div dir="ltr">Hi Luca<div><br></div><div>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.</div><div><br></div><div>Cheers</div><div>Martin</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 17, 2015 at 5:38 AM, Luca Lanteri <span dir="ltr"><<a href="mailto:lklanteri@gmail.com" target="_blank">lklanteri@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div>excuse me for the very very newby question.</div><div><br></div><div>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).</div><div><br></div><div>[0]</div><div>def toggleEdit():</div><div>        aLayer = QgsMapLayerRegistry.instance().mapLayersByName('layer')[0]</div><div>        if not aLayer.isEditable():</div><div>                aLayer.startEditing()</div><div>        else:</div><div>                aLayer.rollBack(True) </div><div><br></div><div>any hint ?</div><div>thanks in advance</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Luca</div><div><br></div><div><br></div></font></span></div>
<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br></div>