[Qgis-developer] Rendering active map symbol as QPixmap

Nathan Woodrow madmanwoo at gmail.com
Thu May 7 15:34:03 PDT 2015


Hey Andrew,

This is how I did it with Roam to get all the legend items for the layer:

items = layer.rendererV2().legendSymbologyItems(ICON_SIZE)

That will give you a list of:Text - Icon pairs

if you are using the rule base renderer you get can the symbol for the rule
and paint that into a pixmap, however note that one feature can have many
symbols so you will have to use the method that returns a list for all the
symbols.

Depending on what you are doing  legendSymbologyItems might give you what
you need without extra work.

- Nathan

On Fri, 8 May 2015 at 07:00 Andrew McClure <andrew at southweb.co.nz> wrote:

> Any takers for this one? I'd like to render the active symbol for a layer
> as a QPixmap in a dialog.
>
> I have got this far:
>
>        s =  layer().rendererV2()
>        key = s.rootRule().findRuleByKey(s.rootRule().ruleKey())
>
> This tells me the active rule key to be rendered but how to get the image
> data?
>
> Perhaps I am barking up the wrong tree here?
>
> Thanks
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150507/db000b79/attachment.html>


More information about the Qgis-developer mailing list