Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Slider with detents?
Forum Updated to NodeBB v4.3 + New Features

Slider with detents?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bovilexic
    wrote on last edited by
    #1

    I've got a request to have sliders with "detent" positions. Not sure if this is the best term, so here's the idea: say you have a slider that goes from -1 to 1, and you want the user to be able to reliably hit the "0" position, by making the slider knob/button "stick" somewhat to that middle point, as he is sliding close to that point.

    I don't see anything in the way of Qt API or stylesheets that can be used to make this work. Any clever ideas, short of writing a new slider subclass (or if someone has done that work, lemme know)?

    Thanks!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joonhwan
      wrote on last edited by
      #2

      maybe you'd like to implement your own QYourSlider::mouseReleaseEvent() where you convert cursor position to slider value and if its value is within the range around your 'quantized' values, set slider position to it.

      _Edited: take a look "here":http://www.qtcentre.org/threads/9208-QSlider-step-customize also _

      joonhwan at gmail dot com

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris H
        wrote on last edited by
        #3

        It might be easiest to just watch the valueChanged() event and if the value is within some epsilon of your "detent" position, manually set the value.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bovilexic
          wrote on last edited by
          #4

          Thanks for the ideas!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved