[Qgis-developer] Error is QgsFeature API Documentation

C Hamilton adenaculture at gmail.com
Tue Feb 14 11:28:14 PST 2017


In the Documentation for QgsFeature

http://qgis.org/api/2.14/classQgsFeature.html

It lists two methods for accessing the attributes

QVariant     attribute (const QString &name) const
QVariant     attribute (int fieldIdx) const

If I use the first method it works fine (ie feature.attribute('City')) ,
but the second (ie feature.attribute(0)) fails with the message

QgsFeature.attribute(QString): argument 1 has unexpected type 'int'

If instead I just use an index such as

feature[fieldIdx]

where feature is a QgsFeature, it works fine.

Am I missing something here or is the second 'attribute' method invalid?

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170214/f12f7d88/attachment-0001.html>


More information about the Qgis-developer mailing list