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
    Commented Jul 15, 2019 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
    Commented Jul 15, 2019 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
    Commented Jul 17, 2019 at 19:14

1 Answer 1


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.

  • I want to write a simple widget with only a description and a colored point (legend). I don't know how to go about it and where to start. Post on QGIS legend widgets by Richard Duivenvoorde unfortunately does not work but it would help me a lot. Please provide available instructions. Commented Feb 15 at 22:40

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.