[Qgis-developer] How to store a QIcon in QGIS project file?

Germán Carrillo carrillo.german at gmail.com
Sat Mar 7 19:56:42 PST 2015


It's a visual guidance to navigate your layer tree. It could help you
differentiate, for example, between data authorities (see an example at
[1]). Additionally, as some user stated in GIS.SE, plugin authors would be
able to differentiate groups created by their plugins from other groups.

I by no means think it's indispensable, but would consider it nice to have.

Regards,

Germán
--
[1] http://downloads.tuxfamily.org/tuxgis/otros/layertree.png

2015-03-07 22:07 GMT-05:00 Nathan Woodrow <madmanwoo at gmail.com>:

> Hey Germán,
>
> What is the purpose of being able to set different group icons?
>
> - Nathan
>
> On Sun, 8 Mar 2015 at 02:06 Germán Carrillo <carrillo.german at gmail.com>
> wrote:
>
>> Hi All,
>>
>> I'd like to add a "Set Group Icon..." action to the context menu for
>> groups in the layer tree. I'm preparing a pull request for that.
>>
>> Everything is working fine, but I have a doubt on how to make the QGIS
>> project to store the QIcon (location), so that when the project is open
>> again, the QIcon can be constructed properly.
>>
>> My first attempt was to store the QIcon path in the project, which works
>> fine when the icon is set through QGIS GUI. However, it wouldn't work for
>> PyQGIS users, who pass a QIcon object to the setIcon() method of
>> QgsLayerTreeGroup. Since QIcon does not store its image file path, it would
>> not be possible to access the path and store it in the project file. I
>> would have to force PyQGIS users to set the image file path via get/set
>> functions iconPath()-setIconPath(), which is not very elegant, but it's the
>> only solution I see.
>>
>> Do you know any other solution for this problem? Perhaps something about
>> storing the QIcon somehow serialized?
>>
>> Regards,
>>
>> Germán Carrillo
>> --
>> -----------
>>   |\__
>> (:>__)(
>>    |/
>> Soluciones Geoinformáticas Libres
>> http://geotux.tuxfamily.org/
>> http://twitter.com/GeoTux2
>>  _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>


-- 
-----------
   |\__
(:>__)(
   |/

Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
http://twitter.com/GeoTux2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150307/66d34184/attachment-0001.html>


More information about the Qgis-developer mailing list