I derive a class and overload postProcessLayer:
class Renamer (QgsProcessingLayerPostProcessorInterface):Near the end of my processAlgorithm implementation I add:
def postProcessLayer(self, layer, context, feedback):
layer.setName('DiffLayer')
print('Renaming layer in post-processor')
details = context.LayerDetails(dest_id,context.project())where dest_id is the value returned by parameterAsSink
details.setPostProcessor(Renamer())
The postProcessLayer method does not appear to run (no output is produced by the print statement) and the layer is added, but the name is unchanged.
I'm not sure if I'm setting up the post process wrong, or not fetching the right LayerDetails object.
Any pointer to how this should be used or an example of its use would be appreciated.
Thanks
David
PS - I also tried the postProcessAlgorithm of the QgsProcessingAlgorithm class, but the layer hasn't been added yet when the method is called. I wonder if I'll have the same problem with the layer post processor?
PPS I tried postProcess, but it doesn't appear to get called as far as I can tell. Not sure why.
def postProcess(self, context, feedback):
print('Number of layers = ' + str(len(QgsProject.instance().mapLayers())))
print("PostProcess completed")
feedback.pushInfo(1) # This line should generate an error since pushInfo expects a string, but no error is thrown
return {self.OUTPUT: self.dest_id}
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
