QGIS and python: Keep a layer always on top of the others

المشرف العام

Administrator
طاقم الإدارة
I am working on a python plugin for QGIS using a layer containing linestrings, which I would like to have on top at all times. I have added the layer like the following:

QgsMapLayerRegistry.instance().addMapLayer(layer, addToLegend=False)I don't want the layer to appear in the Layers Panel.

A similar question has been asked here without an accepted and for me meaningful answer.

According to Nathan W I can use the canvas method setLayerSet to set the render order on the canvas layers.

  • In case the current project already contains several layers, I need to know the current rendering order to correctly place my layer on top without disturbing the current order.
  • In case the user adds a new layer, how do I prevent the new layer from being ontop of mine? Is this handled by listening for some kind of a layer reordered signal on the canvas?
Question: What is the correct approach to handle this issue?



أكثر...
 
أعلى