<div dir="ltr">Hey Adam,<div><br></div><div style>How recent is your build of QGIS?  I just fixed this a couple of days ago.</div><div style><br></div><div style>Regards,</div><div style>Nathan</div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Thu, Jun 6, 2013 at 4:01 PM, Adam Bioletti <span dir="ltr"><<a href="mailto:adamb@wilkinsonmurray.com.au" target="_blank">adamb@wilkinsonmurray.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">







<div lang="EN-AU" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">I am updating a number of locally developed plugins to work with QGIS 1.9.  I am having trouble getting QgsVectorLayer.loadNamedStyle() to work.  I wish to use
 it from within a python plugin.<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">In troubleshooting the issue I have the following code which works from the python console in QGIS 1.8 but not in 1.9.<u></u><u></u></span></font></p>


<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">from qgis.utils import iface # redundant in QGIS 1.9 but doesn’t hurt<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">layers = iface.legendInterface().layers()<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">style = QgsApplication.prefixPath() + "/python/plugins/Gopher2QGIS/styles/SourceLineVertice_Style.qml"<u></u><u></u></span></font></p>


<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">layer.loadNamedStyle(style)<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">layer.triggerRepaint()<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">At the loadNamedStyle point QGIS 1.8 returns:<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">(PyQt4.QtCore.QString(u''), True)<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">QGIS 1.9 returns:<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">(PyQt4.QtCore.QString(u'Loaded from Provider'), True)<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">Both appear to have loaded a style layer (returning a ‘True’ flag if I understand correctly) but the style of the layer in QGIS 1.9 is unchanged.<u></u><u></u></span></font></p>


<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">The style file referenced by each has been created by that version of qgis and loads correctly from the properties dialogue.  Any help that can be provided would
 be greatly appreciated.<u></u><u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial"><u></u> <u></u></span></font></p>
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">Regards<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></font></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><font face="Arial"><span style="font-size:10.0pt;font-family:Arial">Adam Bioletti<u></u><u></u></span></font></p>
<p class="MsoNormal"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><u></u> <u></u></span></font></p>
</font></span></div>
</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>
<br></blockquote></div><br></div>