6

I have a wfs layer loaded in a standalone QGIS app, which I am updating by running a database query on the view it is based on. The feature is added with no problems and I reload the layer with:

# Runs insert query here to add feature to WFS layer source table
wfs_vector_layer.dataProvider().updateExtents()
wfs_vector_layer.dataProvider().reloadData()
main_window.mapCanvas().refresh()

However, the refresh() does not visibly update the canvas, and I have to pan or zoom the canvas to get it to redraw the updated wfs layer with the new feature. I can't see anything more than a refresh() happening after panning from the qgsmaptoolpan source code. Am I using the method incorrectly?

Jochen Schwarze
  • 14,605
  • 7
  • 49
  • 117
James N
  • 531
  • 3
  • 15

1 Answers1

5

Solved it with:

wfs_vector_layer.triggerRepaint()

From this answer: How to automatically reload raster layers if source is changed in QGIS?

James N
  • 531
  • 3
  • 15