# Fetching field values from uncommitted features on Qgis

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 !!

-

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.

-

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 !

-