[QGIS-Developer] Layer inserted into a layertree group using a processing post processor does not repaint on toggle

Tejas L tejvan at live.com
Mon Jul 22 09:01:12 PDT 2019


Hello devs,

I am using the QGIS postprocessing interface to add layers to a layer group. The layer group is created in processAlgorithm, while the indivdual layers are added from postprocessing classses.

The layer group gets created as expected along with the child layers. However toggling the individual layers does not repaint the canvas and has no effect. Toggling the entire group does work though.

The pseudocode is as follows:

def processAlgorithm(...):
    root = context.project().layerTreeRoot()
    group = root.insertGroup(0, "myGroup")

    self.postp = MyPostProcessor(group)

    layer = QgsVectorLayer(...)
    if layer and self.context.willLoadLayerOnCompletion(layer.id()):
       self.context.layerToLoadOnCompletionDetails(layer.id()).setPostProcessor(self.postp).

MyPostProcessor is used to basically move the layer to the group.

When the layer group is also created from within the postprocessing class, everthing works perfectly.

What am I doing wrong?

Regards,
Tej


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190722/c794d689/attachment-0001.html>


More information about the QGIS-Developer mailing list