The vertex tool in red and the geometry displayed by the layer in yellow are not in sync

enter image description here

from time import sleep
from qgis.PyQt.QtSql import QSqlQuery, QSqlDatabase
serverName = 'hostname'
database = 'dbname'
port = 'port'
usr = 'username'
pw = 'password'
uri = QgsDataSourceUri()
uri.setConnection(serverName, port, database, usr, pw)

def stopped(task):
def completed(exception, result=None):
def run(task, wait_time):
    # main code    
    wait_time = wait_time / 100

    Layers= ['120_pipes']

    for i, lyr in enumerate(Layers):
        uri.setDataSource('120', lyr, "wkb_geometry")
        vlayer = QgsVectorLayer(uri.uri(), lyr, "postgres")
        if vlayer.isValid():
            g = QgsProject.instance().layerTreeRoot().insertGroup(0, '120')
            QgsProject.instance().addMapLayer(vlayer, False)
            g.insertChildNode(0, QgsLayerTreeLayer(vlayer))

        if task.isCanceled():
            return None

task = QgsTask.fromFunction(u'Task', run,
                            on_finished=completed, wait_time=50)
  • It looks like the problem is that after you move a vertex with the Vertex Tool, the tool "remembers" where the vertices used to be, and can't detect them at their new location. Can you confirm that I correctly understand the problem? – csk Jul 17 '19 at 18:06
  • @csk, yes this is the problem! – Mariosmsk Jul 17 '19 at 19:17

Your Answer

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

Browse other questions tagged or ask your own question.