[Qgis-developer] layer.hasLabelsEnabled always returning False?

Hugo Mercier hugo.mercier at oslandia.com
Fri Apr 11 05:02:48 PDT 2014


Hi Richard,

Le 11/04/2014 12:01, Richard Duivenvoorde a écrit :
> Hi,
> 
> having a python plugin which is supposed to check if there are labels I
> use someting like this (python console):
> 
> iface.mapCanvas().currentLayer().hasLabelsEnabled()
> 
> (for an active simple point vector layer loaded)
> 
> But this always return False
> 
> is this method not working anymore because we switched label enginges?

Yes, exactly.
I think you should call something like :

settings = QgsPalLayerSettings()
settings.readFromLayer( layer )
if layer.enabled: ...

-- 
Hugo Mercier
Oslandia


More information about the Qgis-developer mailing list