[Qgis-developer] loading/saving subclasses of layers

Martin Dobias wonder.sk at gmail.com
Thu Jan 29 07:52:41 EST 2009

On Thu, Jan 29, 2009 at 12:02 PM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> I've created a subclass of QgsVectorLayer, called 'surveyLayer', in
> python in order to override some of the default methods of
> QgsVectorLayer. My plugin adds a menu item to read data into one of
> these specialised vector layer classes.
> However I can't see how to make sure that when the project is saved
> and loaded that it creates a surveyLayer instead of a plain
> QgsVectorLayer. Currently "Save" just saves it as a normal vector
> layer but without any <symbology> section (because symbology for these
> layers is a bit special and outside the realm of included Qgis
> symbolisers). When loaded, qgis errors on creating the layer because
> of the lack of symbology and says it can't find the shapefile.

Hi Barry,
such things are not supported in QGIS - there's no way for QgsProject
to know that there's some other class than Qgs[Raster|Vector]Layer.
This would require creation of registry of layer types, their
registration etc. And I'm not sure whether this is something really
desired :-)


More information about the Qgis-developer mailing list