Hi Ricardo,<div><br></div><div>For python, looking at the python API is always a good start ;)</div><div><a href="https://qgis.org/pyqgis/master/gui/other/QgisInterface.html#qgis.gui.QgisInterface.registerOptionsWidgetFactory">https://qgis.org/pyqgis/master/gui/other/QgisInterface.html#qgis.gui.QgisInterface.registerOptionsWidgetFactory</a></div><div><br></div><div>This means you must give a QgsOptionsWidgetFactory</div><div><a href="https://qgis.org/pyqgis/master/gui/Options/QgsOptionsWidgetFactory.html">https://qgis.org/pyqgis/master/gui/Options/QgsOptionsWidgetFactory.html</a></div><div><br></div><div>Here the docs could be clearer but this is the class you have to inherit.</div><div>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.</div><div><br></div><div>I hope this helps!</div><div><br></div><div><br></div><div>Denis</div><div><br><div class="gmail_quote"><div dir="ltr">On Wed, 17 Oct 2018, 18:24 Ricardo Filipe Soares Garcia da, <<a href="mailto:ricardo.garcia.silva@gmail.com">ricardo.garcia.silva@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi all</div><div><br></div><div>The API docs for QgisInterface[1] mention the existence of a `registerMapLayerConfigWidgetFactory()` method which says in its documentation:</div><div><br></div><div>> Register a new tab in the vector layer properties dialog. </div><div><br></div><div>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?</div><div><br></div><div>Here is what I have:</div><div><br></div><div>- made a custom .ui file in Qt designer with a simple QWidget that only has a QLabel inside</div><div>- implemented a class inheriting from both `qgis.gui.QgsMapLayerConfigWidget` and my ui file (after it is loaded with uic.loadUiType)</div><div>- 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<br></div><div>- in my plugin's `initGui()` method I'm calling `iface.registerMapLayerConfigWidgetFactory()` and pass along my custom factory</div><div><br></div><div>I guess this should be enough to have a minimum working prototype. However, this is what happens:</div><div><br></div><div>- When I load up a vector layer and then open it's properties dialog, QGIS just crashes with a core dumped message.<br></div><div>- 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?</div><div><br></div><div>Can someone provide some pointers or some existing reference on how this would work? Thanks in advance<br></div><div><br></div><div>[1] - <a href="https://qgis.org/api/classQgisInterface.html#a2c64949239a7717d181e34d6f2c47851" target="_blank">https://qgis.org/api/classQgisInterface.html#a2c64949239a7717d181e34d6f2c47851</a> <br></div></div></div><div dir="ltr"><div dir="ltr"><div><br>-- <br><div dir="ltr" class="m_-2140421326083511896gmail_signature">___________________________ ___ __<br>Ricardo Garcia Silva</div></div></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">
<p class="inbox-inbox-inbox-inbox-p1"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:10pt">Denis Rouzaud</span><br style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a href="mailto:denis@opengis.ch" target="_blank" style="font-family:Times;font-size:medium"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt">denis@opengis.ch</span> </a><br style="color:rgb(0,0,0);font-family:Times;font-size:medium"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt"><a>+41 76 370 21 22</a></span></p><p class="inbox-inbox-inbox-inbox-p1"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt"><a><br></a></span></p></div></div>