QgsFeature feature; feature.setAttribute("name", "John");
QgsFeature feature; feature.setAttribute(0, 123);
QgsFeature feature; QgsFields fields; fields.append(QgsField("name", QVariant::String)); feature.setFields(fields); feature.setAttribute("name", "Jane");This code creates a feature with a single field "name", sets that field to "Jane", and adds it to a vector layer. The QgsFeature class is part of the QGIS library, which is a C++ library for building GIS applications.