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. Configurable QSlider/QDial that uses double values

Configurable QSlider/QDial that uses double values

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 536 Views
  • 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.
  • S Offline
    S Offline
    swurl
    wrote on last edited by
    #1

    What I'm looking for is a configurable, extensible way to use QSliders and QDials with double values.

    I'm aware of the solution involving dividing/multiplying values by a factor of 10, but this is very clunky, unintuitive, and overall confusing. Instead, does there exist a (probably custom) class that has the same functionality as these two slider widgets, but that uses doubles and has a configurable amount of decimal places?

    KenAppleby 0K 1 Reply Last reply
    0
    • S swurl

      What I'm looking for is a configurable, extensible way to use QSliders and QDials with double values.

      I'm aware of the solution involving dividing/multiplying values by a factor of 10, but this is very clunky, unintuitive, and overall confusing. Instead, does there exist a (probably custom) class that has the same functionality as these two slider widgets, but that uses doubles and has a configurable amount of decimal places?

      KenAppleby 0K Offline
      KenAppleby 0K Offline
      KenAppleby 0
      wrote on last edited by
      #2

      @swurl said in Configurable QSlider/QDial that uses double values:

      I'm aware of the solution involving dividing/multiplying values by a factor of 10

      Why 10?

      @swurl said in Configurable QSlider/QDial that uses double values:

      this is very clunky, unintuitive, and overall confusing.

      It really isn't. Perhaps you could define and refine what you would call "intuitive" and then you would see why.

      A slider widget unavoidably operates in discrete values, that is pixels. Integers. Mapping one of these values from an integer range to a double floating point value within another range is trivial maths.

      If you need extreme resolution from the UI, set the minimum and maximum values of the slider to match the likely (virtual) pixel dimensions of your UI element, one pixel per slider value, then do the transform from slider value to your floating point range in the valueChanged signal handler.

      has a configurable amount of decimal places

      That's not up to the slider widget, That's up to the code you write to display the resultant values.

      You could generalise this functionality by creating an adaptor class that handles the slider signals, does the numerical range conversions, formats the results as required and signals the values upwards.

      S 1 Reply Last reply
      4
      • KenAppleby 0K KenAppleby 0

        @swurl said in Configurable QSlider/QDial that uses double values:

        I'm aware of the solution involving dividing/multiplying values by a factor of 10

        Why 10?

        @swurl said in Configurable QSlider/QDial that uses double values:

        this is very clunky, unintuitive, and overall confusing.

        It really isn't. Perhaps you could define and refine what you would call "intuitive" and then you would see why.

        A slider widget unavoidably operates in discrete values, that is pixels. Integers. Mapping one of these values from an integer range to a double floating point value within another range is trivial maths.

        If you need extreme resolution from the UI, set the minimum and maximum values of the slider to match the likely (virtual) pixel dimensions of your UI element, one pixel per slider value, then do the transform from slider value to your floating point range in the valueChanged signal handler.

        has a configurable amount of decimal places

        That's not up to the slider widget, That's up to the code you write to display the resultant values.

        You could generalise this functionality by creating an adaptor class that handles the slider signals, does the numerical range conversions, formats the results as required and signals the values upwards.

        S Offline
        S Offline
        swurl
        wrote on last edited by
        #3

        @KenAppleby-0 said in Configurable QSlider/QDial that uses double values:

        It really isn't. Perhaps you could define and refine what you would call "intuitive" and then you would see why.

        To implement, that is, but I will try your suggestion to create a customizable class... thank you.

        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