[Qgis-developer] using renderers

Marco Hugentobler marco.hugentobler at karto.baug.ethz.ch
Fri Jul 4 02:40:59 EDT 2008


Hi Carson,

You might need to update the legend and call refresh on the mapcanvas:

QgisInterface::refreshLegend(QgsMapLayer*);
QgsMapCanvas::refresh();

Regards,
Marco



Am Freitag 04 Juli 2008 02:28:18 schrieb Carson Farmer:
> Hello list,
>
> This is likely a simple question, but I can't seem to be able to find a
> simple answer:
> I have the following code for creating a continuous color renderer
>
> >         render = QgsContinuousColorRenderer(QGis.Polygon)
> >         render.setClassificationField(0)
> >         symbol1 = QgsSymbol(QGis.Polygon, "", "", "")
> >         symbol2 = QgsSymbol(QGis.Polygon, "", "", "")
> >         symbol1.setFillColor(QColor(Qt.red))
> >         render.setMinimumSymbol(symbol1)
> >         symbol2.setFillColor(QColor(Qt.green))
> >         render.setMaximumSymbol(symbol2)
>
> and then later on I have my vector layer 'vlayer' and use:
> > vlayer.setRenderer(render)
>
> to set the renderer for this layer. Now when I add the layer to the map
> canvas, the renderer settings are set, but they are not displayed until
> I click on 'apply' after right clicking and going to the layers
> properties. So my question is what do I have to add to the above code to
> make this display properly?
>
> Cheers,
>
> Carson
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Dr. Marco Hugentobler
Institute of Cartography
ETH Zurich
Technical Advisor QGIS Project Steering Committee


More information about the Qgis-developer mailing list