QgsFeature feature; feature.setGeometry(QgsGeometry::fromPointXY(QgsPointXY(0,0))); feature.setValid(true);
QgsFeature feature; feature.setGeometry(QgsGeometry::fromPointXY(QgsPointXY(0,0))); feature.setValid(false);In this example, a feature is created and set to have a point geometry at coordinates (0,0). The setValid() method is then called with the parameter set to false, which sets the feature as invalid. Package/Library: QGIS