[Qgis-developer] Getting and setting attribute field names and
values for vector layers
Giuseppe Sucameli
sucameli at faunalia.it
Tue Dec 6 20:06:10 EST 2011
Hi Ole,
to get the field names you have to use the vector data provider.
If vl contains the vector layer than:
provider = vl.dataProvider() # QgsVectorDataProvider
fields = provider.fields() # QMap<int, QgsField>
... # vl.select(), feat = QgsFeature(), while vl.nextFeature(feat):
attrs = feat.attributeMap()
for (k,attr) in attrs.iteritems():
name = fields[ k ].name()
print "%s: %s" % (name, attr.toString())
Regards.
--
Giuseppe Sucameli
More information about the Qgis-developer
mailing list