QgsFeature feature; feature.setAttribute("name", "John"); // set attribute value "John" for attribute named "name"
QgsFeature feature; QString name = feature.attribute("name").toString(); // get attribute value for attribute named "name"This code retrieves the attribute value for a feature. The attribute name is "name" and the value is returned as a QString. The package library for QgsFeature attribute is the QGIS C++ API.