1.创建点图层
QgsVectorLayer * vl1 = new QgsVectorLayer(QStringLiteral("Point?crs=epsg:4326&"), QStringLiteral("points"), QStringLiteral("memory"), QgsVectorLayer::LayerOptions(QgsCoordinateTransformContext()));
QList< QgsMapLayer * > layersvl1;
layersvl1 << vl1;
QgsProject::instance()->addMapLayers(layersvl1);
QgsVectorLayer *vv1 = qobject_cast<QgsVectorLayer *>(vl1);
2.启动编辑
vv1->startEditing();
3.添加点
QgsPointXY xy;
xy.set(0, 0);
QgsGeometry PolygonGeometry = QgsGeometry::fromPointXY(xy);
QgsFeature feature;
feature.setGeometry(PolygonGeometry);
vv1->addFeature(feature);