1

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

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

layer = iface.activeLayer()
layer.setSubsetString('"field"=\'spam\'')
  • My pleasure to help you ;) . Could you accept my answer? – Oscar Campo Mar 29 '18 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 '18 at 1:51

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.