[Qgis-user] Change of selected layer

Carson Farmer carson.farmer at gmail.com
Thu Nov 6 08:44:20 PST 2008


Möri,
> Hi 
>
> I currently try to programm a phyton plugin. Now I have to take some action if the layer in the legend changes, i.e the the current layer changes.  
>  
> I found the signal "selectionChanged (QgsMapLayer *layer)" of the QgsMapCanvas class and guessed, this might do the trick, but the docs says only "Emit map tool changed event" which it also says for the "mapToolSet (QgsMapTool *tool)". So theres some typo or something. 
>  
> My questions: 
> Is the selectionChanged signal emited when the user changes his selection in the legend? If yes, how do I get it? I tried it with 
>  
> QObject.connect(self.iface.mapCanvas(), SIGNAL("selectionChanged (QgsMapLayer *layer)"), self.test) 
>   
try:
QObject.connect(self.iface.mapCanvas(), 
SIGNAL("selectionChanged(QgsMapLayer)"), self.test)

you don't want to have the  *layer, and you don't want a space between 
selectionChanged and (

However, I think selectionChanged refers to feature selection, such that 
it emits a signal with the mapLayer who's selection has changed... I 
could be reading that wrong though...

C



More information about the Qgis-user mailing list