Hi Carson,<br><br>Thanks for your reply<br><br><div class="gmail_quote">2010/11/9 Carson Farmer <span dir="ltr">&lt;<a href="mailto:carson.farmer@gmail.com">carson.farmer@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Kimaidou,<br>
<div class="im"><br>
</div>I suspect that is how most plugin developers have implemented this<br>
functionality, and for the most part it works (save for the situations<br>
you listed below).<br></blockquote><div class="im"><br>Ok<br> <br><br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
One solution would be use userData to store the layers uniqueID, and<br>
then use that to access layers later on.<br>
First you add each layer name to the combobox, like so:<br>
combobox.addItem ( <a href="http://layer.name" target="_blank">layer.name</a>(),QVariant(layer.getLayerID()))<br></blockquote><div><br>UniqueId is the best candidate !<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
and then when the user select a layer from the combobox, get the<br>
maplayer by doing something like (untested):<br>
uniqueId = combobox.itemData(combobox.currentIndex()).toString()<br>
layer = QgsMapLayerRegistry.instance().mapLayer(uniqueId)<br></blockquote><div><br>Ok<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>
Of course, if you are simply listing all layers in the layer list,<br>
then you could just use their order in the combobox, as this will be<br>
the same as the order in the layer list.<br>
layer = mapCanvas.layer(combobox.currentIndex())<br>
<br>
Hope that helps,<br></blockquote><div><br>That helps a lot, thanks !<br><br>Kimaidou<br></div></div>