<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Is editing an existing shape file using C++ supported in QGIS 1.6? Almost all of the tools create a new shape file instead of updating the existing one. I would like to not waste my time if it is not possible to modify/overwrite an existing data file.<br><br>Thank you,<br><br>maaza<br><br>--- On <b>Fri, 4/29/11, maaza mekuria <i>&lt;sailmcm@yahoo.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: maaza mekuria &lt;sailmcm@yahoo.com&gt;<br>Subject: [Qgis-developer] Attribute data update of a shape file<br>To: qgis-developer@lists.osgeo.org<br>Date: Friday, April 29, 2011, 10:56 AM<br><br><div id="yiv1303950513"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font: inherit;" valign="top">Dear QGIS Gurus:<br>I have a written a plugin that updates an attribute
 of a shape file and it tells me it ran fine and yet, I am not able to see the changes in the attribute table once the program finishes. I am using QGIS 1.6 Copiapo on Windows). I am compiling using the 1.7 source, but I have tried using the trunk version and it does not seem to matter at all.<br><br>I can see the edit starting with all the extent selected and it finishes without an error. I also write a log file before and after the feature attribute change and the feature values change correctly.<br>What am i doing wrong?<br><br>The simplified code is posted below,<br><br><code>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; QgsVectorDataProvider* vProvider = theVectorLayer-&gt;dataProvider();<br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; theVectorLayer-&gt;select(vProvider-&gt;attributeIndexes(),
 <br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; theVectorLayer-&gt;extent(), true, false);<br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; QgsFeature currentFeature;<br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; QgsGeometry* currentGeometry = 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool blnEdit = theVectorLayer-&gt;startEditing();<br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; QgsAttributeList attrList = vProvider-&gt;attributeIndexes();<br>&nbsp; &nbsp;&nbsp; &nbsp;vProvider-&gt;select(attrList);<br>&nbsp; &nbsp;&nbsp; &nbsp;blnFeat = vProvider-&gt;nextFeature(currentFeature);<br>&nbsp; &nbsp;&nbsp; &nbsp;QgsAttributeMap atMap1;<br>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vProvider-&gt;createSpatialIndex();<br>&nbsp; &nbsp;&nbsp; &nbsp;QgsAttributeList attrList = vProvider-&gt;attributeIndexes();<br>&nbsp; &nbsp;&nbsp; &nbsp;vProvider-&gt;select(attrList);<br>&nbsp; &nbsp;&nbsp; &nbsp;blnFeat =
 vProvider-&gt;nextFeature(currentFeature);<br>&nbsp; &nbsp;&nbsp; &nbsp;QgsAttributeMap atMap1;<br>&nbsp; &nbsp;&nbsp; &nbsp;QString featureAttributesString;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int ltsVal = 10;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int ltsFldIdx = 1;<br>&nbsp; &nbsp;&nbsp; &nbsp;QVariant fld0 ;<br>&nbsp; &nbsp;&nbsp; &nbsp;while(blnFeat)<br>&nbsp; &nbsp;&nbsp; &nbsp;{<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;atMap1 = currentFeature.attributeMap();<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fld0 = atMap1.value(0);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;currentGeometry = currentFeature.geometry();<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;if(!currentGeometry)<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;continue;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;} <br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
 &nbsp;else<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;currentFeature.changeAttribute(ltsFldIdx,QVariant(ltsVal));&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;blnFeat = vProvider-&gt;nextFeature(currentFeature);<br>&nbsp; &nbsp;&nbsp; &nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;blnAttrAdded = theVectorLayer-&gt;commitChanges();<br>&nbsp; &nbsp;&nbsp; &nbsp;theVectorLayer-&gt;endEditCommand();<br></code></td></tr></tbody></table></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>Qgis-developer mailing list<br><a ymailto="mailto:Qgis-developer@lists.osgeo.org" href="/mc/compose?to=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></div></blockquote></td></tr></table>