For each of my layers, I have various attributes that I might be filtering on, like attribute A < 1000 AND B > 300 etc..

Just like we can add an opacity slider to the legend, I want to be able to add sliders for the various attributes I am filtering on, without having to go into the filter screen and manually change the filter text.

I have seen this answer: Slider for non time attributes in QGIS

And while the hacky solution does work (use Time Manager), it doesn't really work if you want to have multiple sliders to explore your data.

I'm thinking of making something along these lines, but before I do that I figured it's such a useful feature that perhaps there already is a plugin that does it, or some other mechanism. I couldn't find it.

  • 1
    The opacity slider in the legend panel is a "legend widget" or "embedded widget in legend." It might help to search based on those terms. I found this question which has some code that was used to create the opacity slider widget. Maybe you can repurpose it to create your own widget. – csk Jul 15 '19 at 16:30
  • 1
    In the meantime (IE before you finish developing your plugin), you might find a rule-based style easier to use than a filter. – csk Jul 15 '19 at 16:32
  • Thanks @csk! I do use rule based styles, and they are great, but for data exploration they aren't what I want. The legend widget work definitely started me in the right direction. – omar Jul 17 '19 at 19:14

Well, I couldn't find anything. So I made it myself. You can find the code here on github.

I figured out how to do this by starting at this post on QGIS legend widgets by Richard Duivenvoorde.

In the process, I needed a range slider which didn't really exist in PyQt, so I modified this one by Ryan Galloway.

It still needs a bit of work to turn it into a full plugin. When I do that, I'll update this answer. But it's usable, with some kinks. I've been using it to explore some data, and it has been very helpful with that. You can watch this video demo of the filter in action.

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.