<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""><div class="">Yes, that's the point. I was surprised by the fact that those variables where stored as part of the exported qml file. </div><div class=""><br class=""></div><div class="">I was trying to set those variable in processing algorithm so that I could achieve some parametrization of the style associated with the processing output, but no luck</div><div class="">since the qml  overwrite them when loaded in the layer.</div><div class=""><br class="webkit-block-placeholder"></div><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div></div></div><div><blockquote type="cite" class=""><div class="">Le 21 juin 2018 à 11:48, Matthias Kuhn <<a href="mailto:matthias@opengis.ch" class="">matthias@opengis.ch</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi David,<br class=""><br class="">Variables are a part of QML / Layer Style. There is a QEP open about<br class="">handling of this:<br class=""><br class=""><a href="https://github.com/qgis/QGIS-Enhancement-Proposals/issues/125" class="">https://github.com/qgis/QGIS-Enhancement-Proposals/issues/125</a><br class=""><br class="">While variables are not explicitly mentioned in there, it would be good<br class="">to treat them in the same way. I.e. allow exporting and importing QML<br class="">files without variables. This should allow to export and subsequently<br class="">load a style without variables being embedded.<br class="">Would be great if you could add a comment to the QEP.<br class=""><br class="">Thanks<br class="">Matthias<br class=""><br class="">On 06/20/2018 10:06 PM, David Marteau wrote:<br class=""><blockquote type="cite" class=""><br class="">Just found out that this is not addMapLayer that remove the variables<br class="">but 'layer.loadNamedStyle'<br class=""><br class="">Print layer.customProperty('variableNames') just before calling<br class="">'layer.loadNamedStyle' show variables<br class="">Print layer.customProperty('variableNames') just after the call :  empty<br class="">list<br class=""><br class="">Reproduced in the python console:<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">QgsExpressionContextUtils.setLayerVariable(layer,'FOO','BAR')<br class="">layer.customProperty('variableNames')<br class=""></blockquote></blockquote></blockquote>['FOO']<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">layer.loadNamedStyle('mystyle.qml')<br class=""></blockquote></blockquote></blockquote>('', True)<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">layer.customProperty('variableNames')<br class=""></blockquote></blockquote></blockquote>[]<br class=""><br class=""><br class=""><blockquote type="cite" class="">Le 20 juin 2018 à 18:13, David Marteau <dmarteau@3liz.com<br class=""><mailto:dmarteau@3liz.com>> a écrit :<br class=""><br class="">Hi<br class=""><br class="">I'm trying to set custom layers variables from processing<br class="">using  QgsExpressionContextUtils.setLayerVariables to destination<br class="">layers , I have found that those variables does not appear in <br class="">Qgis. <br class=""><br class="">I have found that when the layer is inserted in the current project<br class="">(https://github.com/qgis/QGIS/blob/master/python/plugins/processing/gui/Postprocessing.py#L81)<br class="">the layer variables are removed - Checking existence of the variable<br class="">before<br class="">and after the call of 'addMaperLayer' shows that layer variables are<br class="">removed from custom properties.<br class=""><br class="">I cannot tell if this is a bug or not because it seems that the<br class="">removal may occurs in some signal handler. So if somebody has some<br class="">clues to where to look, I will be grateful.<br class=""><br class=""><br class="">Qgis version: 3.0.3-Girona<br class=""><br class="">David<br class=""></blockquote><br class=""><br class=""><br class="">_______________________________________________<br class="">QGIS-Developer mailing list<br class="">QGIS-Developer@lists.osgeo.org<br class="">List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer<br class="">Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer<br class=""><br class=""></blockquote>_______________________________________________<br class="">QGIS-Developer mailing list<br class="">QGIS-Developer@lists.osgeo.org<br class="">List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer<br class="">Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer</div></div></blockquote></div><br class=""></div></body></html>