[Qgis-user] layer groups with python plugin

Möri Cedric Cedric.Moeri at bd.so.ch
Tue Mar 16 04:26:07 PDT 2010


Hi all

i'm writing a pyhton plugin for adding vector layers. The layers are choosen in a dialog and then loaded into the toc and the canvas:

uri = QgsDataSourceURI()
uri.setConnection(self.DBHOST, self.DBPORT, self.DBNAME, self.DBUSER, "")
 uri.setDataSource("public","table_foo","wkb_geometry")
vLayer = QgsVectorLayer(uri.uri(), "myLayer", "postgres")
QgsMapLayerRegistry.instance().addMapLayer(vLayer)    

This works fine. My question is now, how may I add the layers in a group in the toc? In the layer list you may right click and then add a group and then you may add your layers in the group. That's what I like to do directly with my plugin. 

Is this possible, and if yes, may someone point me to right place in the docs?

regards
Cédric


mit freundlichen Grüssen

Cédric Möri
GIS-Informatiker

--
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
Rötistrasse 4
4501 Solothurn

Telefon: +41 (0)32 627 24 75
Telefax: +41 (0)32 627 22 14
mailto:cedric.moeri at bd.so.ch
http://www.agi.so.ch



More information about the Qgis-user mailing list