2

When I queried some features using QgsFeatureRequest().setFilterExpression() in pyqgis,I want to make the current layer just only show what I queried without creating a new memory layer. Just like you right click on a layer in qgis and filter features you want,the layer will be changed and no new layer will be created.So what should I do? Or is there any other ways without using QgsFeatureRequest().setFilterExpression().

1 Answer 1

3

If I understand the question, it's something like:

layer = iface.activeLayer()
layer.setSubsetString('"field"=\'spam\'')
2
  • My pleasure to help you ;) . Could you accept my answer? Mar 29, 2018 at 9:27
  • Sorry. I didn't see this. I only saw the vote option. I voted for your answer. But the system told me my reputation is not enough. I only got 6. Anyway,thanks again for your help.
    – Guoooo
    Mar 30, 2018 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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