0

I'm working on a Dockwidget with PyQgis.

I made an insert into an Oracle DB and a Spatialite DB and I would like to see the new insert (it's a point).

enter image description here

The Layer where the new point is add is URB_A_ADPT. I'm sure the point is create because I see it in my DB and attribute table. For now, when I zoom and dezoom the point appears but I would like to see it directly.

I tried to simply add

self.refresh = self.canvas.refreshAllLayers()

but it don't seems to be enough to refresh my Oracle layer.

I also tried

if iface.mapCanvas().isCachingEnabled():
    layer.triggerRepaint()
else:
    iface.mapCanvas().refresh()

from the idea of @andreas-müller but once again I don't see anything.

And my last idee was to set zoom and then directly dezoom

active_layer = iface.activeLayer()
active_layer.zoomFull()
active_layer.zoomToPrevious()

but it don't work.

0
if iface.mapCanvas().isCachingEnabled():
    layer.triggerRepaint()
else:
    iface.mapCanvas().refresh()

This one is from the docs, and as mentioned there, it should refresh the query from your database, too.

  • I tried to add it at the end of the function which call my SQL query but it didn't work (I've no error but nothing happend) – Svhooren Dec 4 at 8:01

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.