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:

  1. Click on the Enable Topological Editing button in the Snapping toolbar.

    enter image description here

  2. Start the edit session on both your point and line layers.

  3. Click on Vertex Tool (All layers).

    enter image description here

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:

enter image description here

The code to enable such tool would be:


points = QgsProject.instance().mapLayersByName('points')[0]
lines = QgsProject.instance().mapLayersByName('lines')[0]



Hope this helps!