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

Sandro Mani manisandro at gmail.com
Wed Aug 3 06:25:52 PDT 2016


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.

So I was thinking about whether it would make sense to store the actual 
QgsMapLayer pointers instead of the layerIds in QgsMapSettings, so that 
the whole rendering process is independent of QgsMapLayerRegistry.

I haven't yet investigated extensively how invasive such a change would 
be, but are there some initial opinions?

Thanks
Sandro




More information about the Qgis-developer mailing list