1

How to always run a PyQGIS, in the background?

In my case, I want to delete "feature A", the polygon, that have a "attribute X", if feature B, the lines, that have "attribute X" as well.

enter image description here

  • Search for Qt multi-threading and especially for QThreadPool. Or if it's just a script without GUI interface, go for pure python multi-threading with _thread or threading. – J. Monticolo Jan 29 at 16:53
  • Something like this should be possible using a python script but how will the data be stored, shapefile, dataebase, etc? Will multiple users be involved? I am not sure about the "always in the background" part though. Why do you need it always running? – GreyHippo Jan 29 at 18:08
  • @GreyHippo Thanks, as well as for J.Monticolo ...how will the data be stored, shapefile, dataebase, etc? The feature that the user delete, and the feature that qgis may delete, are PostGIS layer type. Will multiple users be involved? Yes, 10 users using a PostGIS DB Why do you need it always running? Because, the feature I delete is a polygon, and the feature qgis may delete is a line layer that has the side dimension of the polygon, so I can automate the production, as the user don't have to delete the line layer himself. I edited my question, and added a picture of it. – vitorcsm Jan 29 at 21:01
  • 1
    Two ideas to start with: build a trigger on the Postgis side, that fires when the polygon gets deleted. Or connect a script to the signal featureDeleted of the QgsVectorLayer. As this signal informs about the fid of the deleted feature, you need some logic to join this to the line layer – Detlev Jan 30 at 5:40

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.