I am trying to render a number of related QgsRasterLayer objects that are related to eachother (they are slippy-type tiles). Ideally I would like one item in the legend that can have its position changed (i.e. move above or below other legend items) and add custom actions/properties dialog to, but have the actual rendering of the tiles be done by QgsRasterLayer.
My first approach was to attempt to subclass QgsPluginLayer and override the draw() method to call QgsRasterLayer.draw() for each of my loaded rasters. This does nothing, even if layers are added to the QgsMapLayerRegistry.
def draw(self, renderContext): for rasterlayer in self.loadedlayers.values(): rasterlayer.draw(renderContext)My second approach was to create a group in the legend that is somehow hidden. I can add the layer to the layer tree using
mygroup = QgsProject.instance().layerTreeRoot().addGroup("mygroup")for rasterlayer in self.loadedlayers.values(): mygroup.addMapLayer(rasterlayer)but it doesn't seem possible to hide this group from the user. From this question it doesn't seem like there is an alternative. I feel as though there is an easy solution to this that I'm not seeing.
أكثر...
My first approach was to attempt to subclass QgsPluginLayer and override the draw() method to call QgsRasterLayer.draw() for each of my loaded rasters. This does nothing, even if layers are added to the QgsMapLayerRegistry.
def draw(self, renderContext): for rasterlayer in self.loadedlayers.values(): rasterlayer.draw(renderContext)My second approach was to create a group in the legend that is somehow hidden. I can add the layer to the layer tree using
mygroup = QgsProject.instance().layerTreeRoot().addGroup("mygroup")for rasterlayer in self.loadedlayers.values(): mygroup.addMapLayer(rasterlayer)but it doesn't seem possible to hide this group from the user. From this question it doesn't seem like there is an alternative. I feel as though there is an easy solution to this that I'm not seeing.
أكثر...