4

QgsProcessingLayerPostProcessorInterface.postProcessLayer()

vs

QgsProcessingAlgorithm.postProcessAlgorithm()

They both seem to post-process a layer like style it or change its display name. What are the differences and which is the recommended method?

1 Answer 1

5

So after reading through multiple docs and answers. This is my understanding:

QgsProcessingAlgorithm.postProcessAlgorithm() You can do anything here related to canvas or not, literally almost anything. This runs first after the processAlgorithm in QgsProcessingAlgorithm. This is the part of QgsProcessingAlgorithm class.

QgsProcessingLayerPostProcessorInterface.postProcessLayer() On the other hand this is not part of the QgsProcessingAlgorithm class and is run after QgsProcessingAlgorithm is completely finished. It does not do anything apart from attaching its postProcessLayer function to the layer on which it was added. (the function is not executed here)

When QGIS natively outputs layers after the algorithm is finished, it will apply the postProcessLayer function as the last step.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.