QgsPoint point(0, 0); QgsGeometry* geometry = new QgsGeometry(point); QgsFeature feature; feature.setGeometryAndOwnership(geometry);
QgsPolygon polygon; // Populate polygon.... QgsGeometry* geometry = new QgsGeometry(polygon); QgsFeature feature; feature.setGeometryAndOwnership(geometry);In this example, a polygon geometry is created and ownership is transferred to the feature using setGeometryAndOwnership. Package/library: QGIS API for C++.