[QGIS-Developer] Adding Layer tree embedded widgets programmatically
Richard Duivenvoorde
rdmailings at duif.net
Wed Feb 13 03:37:28 PST 2019
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)
More information about the QGIS-Developer
mailing list