[Qgis-developer] How to load a colour table on a raster,
programmatically (in python)?
Benoit EXIGE
benoit at exigesa.com
Tue Aug 10 16:02:42 EDT 2010
Martin,
Thanks for the answers. I will test them tomorrow.
As for QgsLegendInterface the problem was that I did not know how to
use it correctly!
Cheers,
Benoit
On 10 Aug 2010, at 21:52, Martin Dobias <wonder.sk at gmail.com> wrote:
> On Mon, Aug 9, 2010 at 11:01 PM, Benoit de Cabissole <benoit at exigesa.com
> > wrote:
>> Colormap is given to the raster (and into the coloramp tab in the
>> raster
>> properties). The colour ramp attribute is also reflected in the
>> symbology
>> tab: color map combobox set to colormap. So the raster is given the
>> correct
>> info. So far so good. But, the legend does not refresh to show the
>> change to
>> colormap: the raster icon and raster colour bar stay grey.
>
> Use QgsLegendInterface class to refresh the symbology:
>
> iface.legendInterface().refreshLayerSymbology(layer)
>
>
>> The main raster (the only layer in my test) does not refresh either
>> in the
>> QGIS map canvas window. Only if I move it will it refresh and
>> display the
>> colour map.
>
> Possibly you're using caching. Make sure to clear the cached image
> before calling triggerRepaint():
>
> layer.setCacheImage(None)
>
>> The only way to refresh the legend to the correct info seems to
>> open the
>> raster properties box and click ok. (I've tried the
>> QgsLegendInterface, but
>> I have problems to make it work!)
>
> What probles with QgsLegendInterface did you have?
>
>
> Regards
> Martin
More information about the Qgis-developer
mailing list