Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QT Designer - Slider with decimal steps
Forum Updated to NodeBB v4.3 + New Features

QT Designer - Slider with decimal steps

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 2 Posters 2.4k 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.
  • F Offline
    F Offline
    Franco G
    wrote on last edited by
    #1

    Hi all, new here. I am starting with Qt5 and building a control interface based on sliders, doublespinbox and LCDs

    I cannot find a way in QT Designer to set a slider with decimal steps, I will be working with temp and pressure so decimals are mandatory.

    Double spinbox works for that but I would like to have decimals also for sliders. Is this feasible from QT Designer? currently using v 5.15.2

    Thanks in advance

    Franco

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forums

      Im afraid the slider cannot do decimal steps so you are most likely looking at a custom slider
      to make that happen.
      I could not find an example of decimal steps, only using doubles for its value but could be a starting point
      https://stackoverflow.com/questions/19003369/how-to-make-a-qslider-change-with-double-values

      1 Reply Last reply
      3
      • F Offline
        F Offline
        Franco G
        wrote on last edited by
        #3

        THanks for the hint, will work on that

        regards

        Franco

        F 1 Reply Last reply
        0
        • F Franco G

          THanks for the hint, will work on that

          regards

          Franco

          F Offline
          F Offline
          Franco G
          wrote on last edited by
          #4

          At the end I found easier to keep the SLider generated by QT Designer and connect to a simple function scaling the values, like this:

          tempSlider = temperature slider
          tempSpinBox= double Spin Box for temperature

          from slider to spinbox

          self.tempSlider.valueChanged['int'].connect(self.changeTspinBoxValue)

          def changeTspinBoxValue(self,val):
          val = float(val / 10)
          print(val)
          self.tempSpinBox.setValue(val)

          and viceversa for spinbox to slider

          self.tempSpinBox.valueChanged['double'].connect(self.changeTsliderValue)

          def changeTspinBoxValue(self,val):
          val = float(val / 10)
          print(val)
          self.tempSpinBox.setValue(val)

          Thanks

          1 Reply Last reply
          2

          • Login

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