4

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?

4

Solved it with:

wfs_vector_layer.triggerRepaint()

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.