[Qgis-developer] FW: loadNamedStyle in QGIS 1.9

Nathan Woodrow madmanwoo at gmail.com
Wed Jun 5 23:04:37 PDT 2013


Hey Adam,

How recent is your build of QGIS?  I just fixed this a couple of days ago.

Regards,
Nathan


On Thu, Jun 6, 2013 at 4:01 PM, Adam Bioletti
<adamb at wilkinsonmurray.com.au>wrote:

>  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.****
>
> ** **
>
> In troubleshooting the issue I have the following code which works from
> the python console in QGIS 1.8 but not in 1.9.****
>
> ** **
>
> from qgis.utils import iface # redundant in QGIS 1.9 but doesn’t hurt****
>
> layers = iface.legendInterface().layers()****
>
> style = QgsApplication.prefixPath() +
> "/python/plugins/Gopher2QGIS/styles/SourceLineVertice_Style.qml"****
>
> layer.loadNamedStyle(style)****
>
> layer.triggerRepaint()****
>
> ** **
>
> At the loadNamedStyle point QGIS 1.8 returns:****
>
> (PyQt4.QtCore.QString(u''), True)****
>
> ** **
>
> QGIS 1.9 returns:****
>
> (PyQt4.QtCore.QString(u'Loaded from Provider'), True)****
>
> ** **
>
> 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.
> ****
>
> ** **
>
> 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.****
>
> ** **
>
> Regards****
>
> Adam Bioletti****
>
> ** **
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130606/3c5ccb0b/attachment.html>


More information about the Qgis-developer mailing list