[QGIS-Developer] Using embedded widgets in the layer tree on a python plugin

Martin Dobias wonder.sk at gmail.com
Wed Sep 26 12:30:13 PDT 2018


Hi Ricardo

Sorry for the delayed answer...

On Mon, Sep 17, 2018 at 12:10 AM Ricardo Filipe Soares Garcia da
<ricardo.garcia.silva at gmail.com> wrote:
>
> This code kind of works, but I'm facing two problems at the moment:
>
> 1. The `MyWidgetProvider.supportsLayer()` method is never called. The logging call does not show up on the console and I also see that my provider is offered on WMS layers, but also on some local vector layers (which is not what I intend). grep'ping around the QGIS' source code I could not find some place where this method would be called and used, so I'm wondering if this is implemented. I would expect this method to be called when the layer properties dialog is opened, so that my provider would get filtered out for layers that were of the wrong type;
>
> 2. This code does not update the legend for the layer, UNLESS it is a vector layer. If I try to add this provider to a WMS layer, the legend is not updated. If I add it to a shapefile, it works as expected. In order to get my QLabel to show up on WMS layers, I have to manually run this in the QGIS python shell:

I have looked into the code and figured out that both of these issues
seem like bugs in the implementation. The supportLayer() method indeed
seems unused (my test implementation always returned true, that
explains I haven't realized it was not wired in) and the legend
refresh of vector layer is probably done by some other part within the
vector layer properties dialog, while in raster layer properties that
does not happen. Feel free to report them in the bug tracker...

Cheers
Martin


More information about the QGIS-Developer mailing list