[Qgis-developer] QgsMapSettings: store layer pointers instead of layer ids?

Martin Dobias wonder.sk at gmail.com
Wed Aug 3 06:44:00 PDT 2016


Hi Sandro

On Wed, Aug 3, 2016 at 3:25 PM, Sandro Mani <manisandro at gmail.com> wrote:
> Hi
>
> For a project I need independent QgsMapCanvas instances, in particular a
> child view which is unrelated to the main view (including its layertree).
> (Easy example: the main view displays a city, and if the user clicks on a
> "show building schema" button in the building feature attribute dialog, the
> schema of the building is opened in a secondary view. The layers of the
> building schema should not appear in the main layer tree however).
>
> Currently this is not possible: while one can set the layers individually
> for each QgsMapCanvas, the QgsMapSetting ends up storing the layer ids and
> hence they must be stored in the QgsMapLayerRegistry. Items which are stored
> in the QgsMapLayerRegistry will always be visible in the application legend
> tree.

You can use QgsMapLayerRegistry.instance().addMapLayer(layer, False) -
the layer will get to the registry, but it will not end up in the
layer tree. Doesn't it solve your problem?

Cheers
Martin


More information about the Qgis-developer mailing list