Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm developing a small plugin that needs to be able to select a vector layer programatically based on what layer the user has selected. However I'm not sure how to do so.

I believe I found the two elements I need to make it work: setCurrentLayer and selectedLayer from the QgisLegendInterface, but I'm not certain how they work or how they are implemented, I cannot either find any examples of them other than in the API.

Am I close? Or is there a better/proper form of doing this?

share|improve this question
    
try to read qgis.org/pyqgis-cookbook ..most probably you would be able to answer yourself then –  vinayan Mar 7 '13 at 2:55

1 Answer 1

up vote 1 down vote accepted

You can use the qgis.util.iface object which will give you access to all layers including the current selected layer:

myLayer = qgis.utils.iface.activeLayer()

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.