Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to fetch a feature's field value on Qgis, I use

QgsFeature.attributeMap().value(cont int & key).toDouble()

This works fine for committed features but it always returns " 0 " if the feature is not yet committed to the vector layer !!

share|improve this question

QgsFeature is just temporary entity that is returned from the layer or the provider. QgsFeature doesn't "know" where the data originated from.

I suppose you're fetching directly from the provider, but to get the uncommitted changes you must fetch the feature from the layer.

share|improve this answer
up vote 0 down vote accepted

I'm iterating over the layer's features to get a specific feature with :

pQgsVlayer->select( attributeList, pQgsVlayer->extent() );
QgsFeature tFeature;
while ( pQgsVlayer->nextFeature(tFeature) ){

Here, attributes are fetched to the QgsFeature resulting from nextFeature(..) !

The problem was that I get the feature's Id from this iteration then I use it to get to the feature when needed with :

pQgsVlayer->featureAtId(id, Feature);

uncommitted attributes are, then, not fetched !

I solved this by using to iteration to get the feature itself not the id, so it will have all of its attributes when I use it !

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.