[Qgis-developer] FW: loadNamedStyle in QGIS 1.9

Adam Bioletti adamb at wilkinsonmurray.com.au
Wed Jun 5 23:01:52 PDT 2013


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130606/a669c050/attachment.html>


More information about the Qgis-developer mailing list