[QGIS-Developer] Adding a panel to layer properties dialog from a python plugin
denis.rouzaud at gmail.com
Thu Oct 18 03:32:42 PDT 2018
Sorry I pasted the wrong links...
This was for adding a page to global options.
Here it is for layers.
There you have to implement supports layers. So it is very likely that it
will work for rasters but did not check.
On Thu, 18 Oct 2018, 03:37 Ricardo Filipe Soares Garcia da, <
ricardo.garcia.silva at gmail.com> wrote:
> Hi Denis, all
> I keep forgetting there are now also (totally cool) docs for the python
> API... I guess old habits die hard ;)
> From your tip I guess the problem I'm facing is likely related to my class
> inheriting from the wrong base ( as I'm not using QgsOptionsPageWidget).
> I'll try it out later and let you know ;)
> As for the raster layer properties dialog , is this indeed not implemented
> Best regards
> Denis Rouzaud <denis.rouzaud at gmail.com> escreveu no dia quinta,
> 18/10/2018 à(s) 01:49:
>> Hi Ricardo,
>> For python, looking at the python API is always a good start ;)
>> This means you must give a QgsOptionsWidgetFactory
>> Here the docs could be clearer but this is the class you have to inherit.
>> You need to implement title, icon and createWidget. In the latter, you'll
>> be able to load your UI and return the widget to be displayed. The widget
>> you return must inherit QgsOptionsPageWidget.
>> I hope this helps!
>> On Wed, 17 Oct 2018, 18:24 Ricardo Filipe Soares Garcia da, <
>> ricardo.garcia.silva at gmail.com> wrote:
>>> Hi all
>>> The API docs for QgisInterface mention the existence of a
>>> `registerMapLayerConfigWidgetFactory()` method which says in its
>>> > 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
>>> - 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
>>> 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
>>>  -
>>> ___________________________ ___ __
>>> Ricardo Garcia Silva
>>> 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
>> Denis Rouzaud
>> denis at opengis.ch <denis at opengis.ch>
>> +41 76 370 21 22
> ___________________________ ___ __
> Ricardo Garcia Silva
> 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
denis at opengis.ch <denis at opengis.ch>
+41 76 370 21 22
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the QGIS-Developer