<div dir="ltr"><div dir="ltr" style="color:rgb(0,0,0);font-size:13px">Thanks Alain, that would imply creating a new class in the QGIS source code, and, unless other parts of the code needed it, I think it woudn't be welcomed.<div><br></div><div>Regards, </div><div><br></div><div>Germán</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-03-07 12:38 GMT-05:00 alain <span dir="ltr"><<a href="mailto:al.bertho@free.fr" target="_blank">al.bertho@free.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
Maybe you can use a derived class, in python this would look like:<br>
<br>
QIconWithPath(QIcon):<br>
def __init__(self,iconPath):<br>
super(QIconWithPath,self).__init__(iconPath)<br>
self.setIconPath(iconPath)<br>
<br>
I'm not sure this is considered elegant...<br>
<br>
Alain<br>
<br>
<div>Le 07/03/2015 17:06, Germán Carrillo a
écrit :<br>
</div>
<blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi All,
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Do you know any other solution for this problem? Perhaps
something about storing the QIcon somehow serialized? </div>
<div><br>
</div>
<div>Regards, </div>
<div><br>
</div>
<div>Germán Carrillo<br>
-- <br>
<div>-----------<br>
|\__ <br>
(:>__)(<br>
|/ <br>
Soluciones Geoinformáticas Libres
<br>
<a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br>
<a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a><br>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">-----------<br> |\__ <br>(:>__)(<br> |/ <br><br>Soluciones Geoinformáticas Libres <br><a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2">http://twitter.com/GeoTux2</a><br></div>
</div></div>