Dragging all vertices at a given point programmatically in PyQGIS
This can be done using QGIS tools that you can enable programmatically. That is, there is no need to reinvent the wheel.
Namely, you need to:
Click on the
Enable Topological Editing
button in theSnapping toolbar
.Start the edit session on both your point and line layers.
Click on
Vertex Tool (All layers)
.
This enables a tool that you can use to move a common vertex in both point and line layers, as you can see in this GIF:
The code to enable such tool would be:
QgsProject.instance().setTopologicalEditing(True)
points = QgsProject.instance().mapLayersByName('points')[0]
lines = QgsProject.instance().mapLayersByName('lines')[0]
points.startEditing()
lines.startEditing()
iface.layerTreeView().setCurrentLayer(points)
iface.actionVertexTool().trigger()
Hope this helps!