Legend Qgis With Python
Legend Qgis With Python
http://geotux.tuxfamily.org/index.php/en/component/k2/item/270-tabla-de-contenido-leyenda-paraaplicaciones-basadas-en-pyqgis/
self.createLegendWidget()
resources_prefix = ":/legend/imgs/"
5. Let the legend to load and remove layers in order to avoid segmentation fault.
You must have a method to load layers into your map application, but now that you want to include a layer list widget
you should let it control all these matters. The layer list widget has a SLOT to manage the layer set at the time you
load, move or remove a layer. All you have to do is to call the appropriate methods (either addMapLayer or
removeMapLayer) from QgsMapLayerRegistry instance, but do not use the setLayerSet canvas method yourself, the
new widget will. So, comment or delete your setLayerSet calls.
QgsMapLayerRegistry.instance().addMapLayer( layer );
#self.canvas.setLayerSet( self.layers )
6. Load the properties dialog.
To allow the user set some layer properties you have to compile the dlgLayerProperties.ui file, which will provide a
basic dialog.
return self.legend.activeLayer()
self.legend.refreshLayerSymbology( layer )
self.legend.removeLayers( layerIds )
That's it!