[Qgis-developer] load layer style failed - possible bug?

Luca Mandolesi mandoluca at gmail.com
Mon Jul 20 05:39:50 EDT 2009


>
> How are you trying to load the qml?   Loading with
> QgsMapLayer::loadNamedStyle() should work with any path.


layerCA.loadNamedStyle('/Users/.qgis/python/plugins/pyarchinitus/modules/gis/styles/previewCAstyle.qml')

If you want to have QGIS automatically loaded the qml when you load the
> layer
> the qml needs to reside in the same directory and have the same name as the
> vector data source.


I have 2 layers into postgres/postgis DB. The problem appears only into
/.qgis directory.
This is a piece of code:

if  layerUS.isValid() == True and layerCA.isValid() == True:
USLayerId = layerUS.getLayerID()
CALayerId = layerCA.getLayerID()
layerUS.loadNamedStyle('/Users/.qgis/python/plugins/pyarchinitus/modules/gis/styles/previewUSstyle.qml')
layerCA.loadNamedStyle('/Users/.qgis/python/plugins/pyarchinitus/modules/gis/styles/previewCAstyle.qml')
QgsMapLayerRegistry.instance().addMapLayer(layerUS, False)
QgsMapLayerRegistry.instance().addMapLayer(layerCA, False)
layerToSet = [ QgsMapCanvasLayer(layerCA, True, False),
QgsMapCanvasLayer(layerUS, True, False) ]
elif layerUS.isValid() == True and layerCA.isValid() == False:
CALayerId = None
USLayerId = layerUS.getLayerID()
layerUS.loadNamedStyle('/Users/.qgis/python/plugins/pyarchinitus/modules/gis/styles/previewUSstyle.qml')
QgsMapLayerRegistry.instance().addMapLayer(layerUS, False)
layerToSet = [ QgsMapCanvasLayer(layerUS, True, False) ]
elif layerUS.isValid() == False and layerCA.isValid() == True:
USLayerId = None
CALayerId = layerCA.getLayerID()
layerCA.loadNamedStyle('/Users/.qgis/python/plugins/pyarchinitus/modules/gis/styles/previewCAstyle.qml')
QgsMapLayerRegistry.instance().addMapLayer(layerCA, False)
layerToSet = [ QgsMapCanvasLayer(layerCA, True, False) ]
elif layerUS.isValid() == False and layerCA.isValid() == False:
USLayerId = None
CALayerId = None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090720/066ad8ea/attachment.html


More information about the Qgis-developer mailing list