Hi Carson, Thanks for your reply
2010/11/9 Carson Farmer <[email protected]> > Hi Kimaidou, > > I suspect that is how most plugin developers have implemented this > functionality, and for the most part it works (save for the situations > you listed below). > Ok One solution would be use userData to store the layers uniqueID, and > then use that to access layers later on. > First you add each layer name to the combobox, like so: > combobox.addItem ( layer.name(),QVariant(layer.getLayerID())) > UniqueId is the best candidate ! > > and then when the user select a layer from the combobox, get the > maplayer by doing something like (untested): > uniqueId = combobox.itemData(combobox.currentIndex()).toString() > layer = QgsMapLayerRegistry.instance().mapLayer(uniqueId) > Ok > > Of course, if you are simply listing all layers in the layer list, > then you could just use their order in the combobox, as this will be > the same as the order in the layer list. > layer = mapCanvas.layer(combobox.currentIndex()) > > Hope that helps, > That helps a lot, thanks ! Kimaidou
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
