[QGIS-Developer] Adding Layer tree embedded widgets programmatically

Raymond Nijssen r.nijssen at terglobo.nl
Wed Feb 13 03:59:10 PST 2019


Hi Richard,

Here is some example code. I will try to make it work now.

Groetjes!
Raymond


On 13-02-19 12:37, Richard Duivenvoorde wrote:
> Hi Devs,
> 
> Thinking about creating a small plugin which would add a 'Layer tree
> embedded widget' to a layer in the legend, I hit:
> 
> https://github.com/qgis/QGIS/pull/3170
> 
> with a nice example on how to create such a widget (with 2 minor tweaks
> see below).
> 
> But my question is if it is possible (in the python plugin) to attach
> such widget to a specific layer? Now it is working but you can only
> activate it via the layerproperties dialog.
> 
> I could not find a example or hint for it.
> 
> Any pointers appreciated.
> 
> Regards,
> 
> Richard Duivenvoorde
> 
> PS
> 
> To make Martins example https://github.com/qgis/QGIS/pull/3170) work in
> QGIS3:
> 
> from PyQt4.QtGui import QComboBox
> becomes
> from qgis.PyQt.QtWidgets import QComboBox
> 
> QgsLayerTreeEmbeddedWidgetRegistry.instance().addProvider(provider)
> becomes
> QgsGui.layerTreeEmbeddedWidgetRegistry().addProvider(provider)
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 


More information about the QGIS-Developer mailing list