I am using a database view as a source to draw a line over a map in QGIS 2.18.12. This view contains just one registration and it changes from time to time. I would like to draw the line automatically when the view changes. Is it possible to do this from a Python script? For the moment my solution is to reload the whole project, but it is not as fine as I expected because I want to refresh just the line not all layers.
The code I use now is:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
from qgis.gui import *
from qgis.utils import iface
from PyQt4.QtCore import QTimer
timer = QTimer()
timer.setInterval(10000)
QObject.connect(timer,
SIGNAL("timeout()"),qgis.utils.iface.mapCanvas().refreshAllLayers)
timer.start()
for layer in qgis.utils.iface.mapCanvas().layers():then inspectlayerto see if it matches your criteria, thenlayer.triggerRepaint()? – alphabetasoup Nov 27 '18 at 10:35