Found the answer to my own question in old posts here. (Thank you Matteo!)

I have added this code to the processAlgorithm() function:

```
        context.addLayerToLoadOnCompletion(
            f'{gpkg_fn}|layername=my_view',
            context.LayerDetails(
                    name='my_view',
                    project=context.project()
                )
        )
```

Seems to work at least.

Raymond


On 07-08-2023 20:18, Raymond Nijssen via QGIS-Developer wrote:
Hi developers,

I have created a processing algorithm in python that creates a new gpkg database with a bunch of tables and views. One of the views can be loaded as a polygon layer, which works fine when loaded manually.

How can I tell QGIS to load that view as a polygon layer when the algorithm has finished? (I think it must be the same as telling the layername to load from the geopackage)

So far, I have tried both QgsProcessingParameterFileDestination and QgsProcessingParameterVectorDestination as output parameters without much luck.

Hope anyone can help. Kind regards,
Raymond
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to