[Qgis-developer] Attribute data update of a shape file

maaza mekuria sailmcm at yahoo.com
Sat Apr 30 02:14:12 EDT 2011

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.

Thank you,


--- On Fri, 4/29/11, maaza mekuria <sailmcm at yahoo.com> wrote:

From: maaza mekuria <sailmcm at yahoo.com>
Subject: [Qgis-developer] Attribute data update of a shape file
To: qgis-developer at lists.osgeo.org
Date: Friday, April 29, 2011, 10:56 AM

Dear QGIS Gurus:
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.

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.
What am i doing wrong?

The simplified code is posted below,

           QgsVectorDataProvider* vProvider = theVectorLayer->dataProvider();
           theVectorLayer->extent(), true, false);
           QgsFeature currentFeature;
           QgsGeometry* currentGeometry = 0;
                bool blnEdit = theVectorLayer->startEditing();
           QgsAttributeList attrList = vProvider->attributeIndexes();
      blnFeat = vProvider->nextFeature(currentFeature);
      QgsAttributeMap atMap1;
      QgsAttributeList attrList = vProvider->attributeIndexes();
      blnFeat =
      QgsAttributeMap atMap1;
      QString featureAttributesString;
                int ltsVal = 10;
                int ltsFldIdx = 1;
      QVariant fld0 ;
                       atMap1 = currentFeature.attributeMap();
         fld0 = atMap1.value(0);
         currentGeometry = currentFeature.geometry();
         blnFeat = vProvider->nextFeature(currentFeature);
      blnAttrAdded = theVectorLayer->commitChanges();

-----Inline Attachment Follows-----

Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110429/5aed8920/attachment.html

More information about the Qgis-developer mailing list