[QGIS-Developer] Adding a panel to layer properties dialog from a python plugin

Ricardo Filipe Soares Garcia da ricardo.garcia.silva at gmail.com
Wed Oct 17 15:23:47 PDT 2018


Hi all

The API docs for QgisInterface[1] mention the existence of a
`registerMapLayerConfigWidgetFactory()` method which says in its
documentation:

> Register a new tab in the vector layer properties dialog.

I've been trying to test this out and see if I can add a new panel to a
layer's properties dialog via a Python plugin. So far I've had no luck.
Couldn't find any other docs/samples online showing how to do this. Perhaps
someone can help me out?

Here is what I have:

-  made a custom .ui file in Qt designer with a simple QWidget that only
has a QLabel inside
-  implemented a class inheriting from both
`qgis.gui.QgsMapLayerConfigWidget` and my ui file (after it is loaded with
uic.loadUiType)
- implemented a class inheriting from
`qgis.gui.QgsMapLayerConfigWidgetFactory`. This class implements all of the
methods declared as *virtual* in the cpp API, including the
`createWidget()`, which returns a new instance of my custom
maplayerconfigwidget class
- in my plugin's `initGui()` method I'm calling
`iface.registerMapLayerConfigWidgetFactory()` and pass along my custom
factory

I guess this should be enough to have a minimum working prototype. However,
this is what happens:

- When I load up a vector layer and then open it's properties dialog, QGIS
just crashes with a core dumped message.
- When I load up a raster layer and then open it's properties dialog,
nothing happens. I suspect this functionality is probably not even
available for raster layers. Is this true?

Can someone provide some pointers or some existing reference on how this
would work? Thanks in advance

[1] -
https://qgis.org/api/classQgisInterface.html#a2c64949239a7717d181e34d6f2c47851

-- 
___________________________ ___ __
Ricardo Garcia Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20181017/5b598a01/attachment.html>


More information about the QGIS-Developer mailing list