Re: [QGIS-Developer] Load layer with style in Processing plugin
Hi Nyall, thanks for the answer. > In 3.2 it should be possible, using a subclass of > QgsProcessingLayerPostProcessorInterface and > > context.layerToLoadOnCompletionDetails( output_dest_id > ).setPostProcessor( my_layer_post_processor() ) > > Your QgsProcessingLayerPostProcessorInterface subclass would set the > style for the layer in its postProcessLayer implementation. > > This is the canonical, thread safe way to do this in processing... any > other approach (and there's other hacky ways to do this) will not be > thread safe and may crash! We probably should make this a bit easier > and have a direct `context.layerToLoadOnCompletionDetails( > output_dest_id ).setLayerStyle(. )` call, but it's too late for > 3.2 eheh, sorry too late to test all Processing options (too many of them ;) ). what you suggested to implement in the future sounds as the smoothest idea. Thanks again for the hints! Matteo ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Load layer with style in Processing plugin
On 30 May 2018 at 20:22, matteo wrote: > Hi devs, > > is it possible to load a layer (vector or raster) created in a > Processing script/algorithm from the script itself without using the > specific algorithm "set style for raster layer"? > > I'm using context.addLayerToLoadOnCompletion() to load the layers and I > have a separated function that creates the style (as qml file with the > same name of the layer). But when the layers are loaded the styles > aren't (even if correctly created in the folder and it works if manually > loaded in QGIS). > > Thanks for any suggestion In 3.2 it should be possible, using a subclass of QgsProcessingLayerPostProcessorInterface and context.layerToLoadOnCompletionDetails( output_dest_id ).setPostProcessor( my_layer_post_processor() ) Your QgsProcessingLayerPostProcessorInterface subclass would set the style for the layer in its postProcessLayer implementation. This is the canonical, thread safe way to do this in processing... any other approach (and there's other hacky ways to do this) will not be thread safe and may crash! We probably should make this a bit easier and have a direct `context.layerToLoadOnCompletionDetails( output_dest_id ).setLayerStyle(. )` call, but it's too late for 3.2 Nyall ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] Load layer with style in Processing plugin
Hi devs, is it possible to load a layer (vector or raster) created in a Processing script/algorithm from the script itself without using the specific algorithm "set style for raster layer"? I'm using context.addLayerToLoadOnCompletion() to load the layers and I have a separated function that creates the style (as qml file with the same name of the layer). But when the layers are loaded the styles aren't (even if correctly created in the folder and it works if manually loaded in QGIS). Thanks for any suggestion Cheers Matteo ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer