[Qgis-developer] Re: scaling points size according to attribute values

Martin Dobias wonder.sk at gmail.com
Tue Jan 5 09:17:01 EST 2010


Hi Ricardo

On Thu, Dec 31, 2009 at 3:07 AM, Ricardo Filipe Soares Garcia da
<ricardo.garcia.silva at gmail.com> wrote:
> [...]
> symbol.setScaleClassificationField(provider.fieldNameIndex("gid"))
> newRend = QgsSingleSymbolRenderer(layer.geometryType())
> newRend.addSymbol(symbol)
> layer.setRenderer(newRend)
> layer.triggerRepaint()
>
>
> To be honest I was amazed that this worked. The reason for that is
> that the class QgsSingleSymbolRenderer is supposed (as shown by the
> online API docs) to have an updateSymbolAttributes() method. This
> method is in fact mysteriously missing from the python bindings... I
> don't know how but it seems there is some other method that updates
> the symbols' properties and my code is somehow calling it. I guess its
> the triggerRepaint() slot of QgsVectorLayer that originates this
> updating of the symbols' properties...

Indeed that updateSymbolAttributes() method was missing in the python
bindings. I've added it in now in trunk (r12672). Also there was
missing automatic conversion from QgsRenderer to the subclasses, e.g.
QgsSingleSymbolRenderer (fixed in the same commit). So from now you
can use the "right" approach too but I would recommend you to keep
your workaround for compatibility with older releases.


> I also didn't understand why it was needed to create a new
> QgsSingleSymbolRenderer instead of just changing the old one, which
> didn't work...

That's because when calling single symbol renderer's addSymbol()
method, the updateSymbolAttributes() method is called in it.


Regards
Martin


More information about the Qgis-developer mailing list