Wednesday, 27 November 2019

qgis - Why is the SelectionChanged signal triggered every time i click on the layer?


i'm making some experiments with the SelectionChanged signal of a QgsVectorLayer.


i try this piece of code :


curLayer.selectionChanged.connect(self.test)

and "test" print a warning message.


The probleme i have is that the signal is triggered every time i click on the layer, even when there's no change of selection ...


Is there something i'm missing in this SelectionChanged behaviour ?



Thanks for your help.



Answer



Ok then, after a few searches :


U got to use the two lists provided by the SelectionChanged signal :


QgsFeatureIds selected,QgsFeatureIds deselected (as mentionned in the API doc...)

to check what is really changing in your selection, of course multiple features selection is to take in account ...


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...