Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtControls.slider.value returns with decimal points when moved.
Forum Updated to NodeBB v4.3 + New Features

QtControls.slider.value returns with decimal points when moved.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 330 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.
  • M Offline
    M Offline
    Makarand_EB
    wrote on 4 Aug 2020, 12:54 last edited by Makarand_EB 8 Apr 2020, 13:05
    #1

    I am using a Slider with below properties set for it -

    Item {
    id: root
    signal sliderMoved
    property alias value: control.value

    QtControls.Slider {
    orientation: Qt.Vertical
    snapMode: QtControls.Slider.SnapOnRelease
    from: 59.0
    to: 86.0
    stepSize : 1.0
    onMoved: root.sliderMoved()
    }
    }

    From user QML where this slider is used thru loader

    Connections {
    target: sliderLoader.item
    onSliderMoved: {
    console.warn(sliderLoader.item.value);
    }
    }

    But eachtime when the slider is dragged, it returns the value with decimal points. I am expecting value like 59,60,61, 62.....till 86 not like 59.12, 63.45 etc. How to get rid of these decimal points from the returned slider value when the slider is moved

    O 1 Reply Last reply 4 Aug 2020, 13:00
    0
    • M Makarand_EB
      4 Aug 2020, 12:54

      I am using a Slider with below properties set for it -

      Item {
      id: root
      signal sliderMoved
      property alias value: control.value

      QtControls.Slider {
      orientation: Qt.Vertical
      snapMode: QtControls.Slider.SnapOnRelease
      from: 59.0
      to: 86.0
      stepSize : 1.0
      onMoved: root.sliderMoved()
      }
      }

      From user QML where this slider is used thru loader

      Connections {
      target: sliderLoader.item
      onSliderMoved: {
      console.warn(sliderLoader.item.value);
      }
      }

      But eachtime when the slider is dragged, it returns the value with decimal points. I am expecting value like 59,60,61, 62.....till 86 not like 59.12, 63.45 etc. How to get rid of these decimal points from the returned slider value when the slider is moved

      O Offline
      O Offline
      ODБOï
      wrote on 4 Aug 2020, 13:00 last edited by
      #2

      hi,

      @Makarand_EB said in QtControls.slider.value returns with decimal points when moved.:

      stepsize : 1.0

      stepSize : 1 // note the uppercase "S"

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Makarand_EB
        wrote on 4 Aug 2020, 13:25 last edited by
        #3

        Thanks, I update the code.

        1 Reply Last reply
        0

        1/3

        4 Aug 2020, 12:54

        • Login

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