Once created a layer, how can I hide/show it? I can enable/disable rendering of a specific layer by selecting the checkbox through QGIS, but I need to do it programmatically from python code.
How can I show/hide(not remove) a label from python code?
I'm looking for something like:
aLayer = self.addVectorLayer(uri.uri(), layerName, self.dbConn.getProviderName())
aLayer.Hide()
....
aLayer.Show()
Best Answer
You can control the layer visibility through the legend object. Here it is, using your sample code above:
Here's the documentation for
legendInterface
: http://qgis.org/api/classQgsLegendInterface.htmlGood luck!