[QGIS-trac] Re: [Quantum GIS] #1462: PostGIS layer loaded via
Python is not saved correct in qgs project file
Quantum GIS
qgis at qgis.org
Mon Dec 15 07:11:04 EST 2008
#1462: PostGIS layer loaded via Python is not saved correct in qgs project file
--------------------------------------------------------------+-------------
Reporter: hdus | Owner: jef
Type: bug | Status: new
Priority: critical: causes crash or data corruption | Milestone: Version 1.0.0
Component: Project Loading / Saving | Version: HEAD
Resolution: | Keywords:
Platform_version: | Platform: All
Must_fix: No | Status_info: 0
--------------------------------------------------------------+-------------
Comment (by hdus):
Replying to [comment:1 jef]:
> I tried to run your code in the python console. When try to save I get
>
> {{{
> NotImplementedError: QgsVectorLayer.writeSymbology() is abstract and
must be overridden
> }}}
>
> I still need to investigate why there's python code fired at all at that
point, but if I replace
>
> {{{
> vlayer = QgsVectorLayer(uri.uri(), layerName, "postgres")
> QgsMapLayerRegistry.instance().addMapLayer(vlayer)
> }}}
>
> with
>
> {{{
> iface.addVectorLayer(uri.uri(), layerName, "postgres")
> }}}
>
> everything is fine again.
Your workaround works fine for me too. But how do I load a namedStyle to
this layer? With my version I can prepare a vLayer object and I'm able to
add a symbolisation with {{{vLayer.loadNamedStyle()}}} before I register
the vLayer. I tried
{{{
self.iface.addVectorLayer(uri.uri(), layerName, "postgres")
vLayer = self.iface.mapCanvas().currentLayer()
vLayer.loadNamedStyle(Path to qml-file)
}}}
in this case the symbolisation in mapcanvas is updated, but the legend
symbolisation is not changed.
--
Ticket URL: <https://trac.osgeo.org/qgis/ticket/1462#comment:2>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats
More information about the QGIS-trac
mailing list