1

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?

1

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()

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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