Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment
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
add comment

Your Answer

 
discard

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.