QgsFeature feature(layer->fields()); QListattributes; attributes << "New feature" << 10 << 3.14 << 1; feature.setAttributes(attributes); layer->addFeature(feature);
QgsFeature feature = layer->getFeature(1); QListIn this example, we retrieve an existing feature from the layer, get the current attribute values with the attributes function, update some of the values in the QList of QVariant objects, and set them back in the feature with the setAttributes function. Finally, we update the feature in the layer. The package library for QgsFeature setAttributes is QGIS.attributes = feature.attributes(); attributes[0] = "Updated feature"; attributes[3] = 2; feature.setAttributes(attributes); layer->updateFeature(feature);