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. Qslider:setting float value
Forum Updated to NodeBB v4.3 + New Features

Qslider:setting float value

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 7.9k 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.
  • D Offline
    D Offline
    drd1988on
    wrote on last edited by
    #1

    Hi
    I wants to use a fm slider in my project .For that I am using QSlider.But upon moving the handle of the slider,am only getting int value.If am moving the slider to 91.9,valueChanged function vl give 91 and If I move to 91 it vl show 91 only.
    Here is my code

      m_fmSlider = new QSlider(this);
      m_fmSlider->setOrientation(Qt::Horizontal);
       m_fmSlider->setGeometry(200,25,734,130);
    
    m_fmSlider->setMaximum(107);
    m_fmSlider->setMinimum(87);
    m_fmSlider->setTickPosition(QSlider::TicksBothSides);
        m_fmSlider->setTickInterval(10);
        m_fmSlider->setSingleStep(1);
    
    m_fmSlider->setStyleSheet(
    
                "QSlider::groove:horizontal  {image: url(:/images/fm_scale.png);}"
                "QSlider::handle {image: url(:/images/radio_station_thumb.png);}"
    

    );
    connect(m_fmSlider, SIGNAL (sliderMoved(int )), this, SLOT (slot_onSliderMoved(int )));

    Regards
    Divya0_1555049906137_fm_scale.png

    jsulmJ 1 Reply Last reply
    0
    • D drd1988on

      Hi
      I wants to use a fm slider in my project .For that I am using QSlider.But upon moving the handle of the slider,am only getting int value.If am moving the slider to 91.9,valueChanged function vl give 91 and If I move to 91 it vl show 91 only.
      Here is my code

        m_fmSlider = new QSlider(this);
        m_fmSlider->setOrientation(Qt::Horizontal);
         m_fmSlider->setGeometry(200,25,734,130);
      
      m_fmSlider->setMaximum(107);
      m_fmSlider->setMinimum(87);
      m_fmSlider->setTickPosition(QSlider::TicksBothSides);
          m_fmSlider->setTickInterval(10);
          m_fmSlider->setSingleStep(1);
      
      m_fmSlider->setStyleSheet(
      
                  "QSlider::groove:horizontal  {image: url(:/images/fm_scale.png);}"
                  "QSlider::handle {image: url(:/images/radio_station_thumb.png);}"
      

      );
      connect(m_fmSlider, SIGNAL (sliderMoved(int )), this, SLOT (slot_onSliderMoved(int )));

      Regards
      Divya0_1555049906137_fm_scale.png

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @drd1988on That's because slider works with integer values.
      Take a look at this: https://stackoverflow.com/questions/19003369/how-to-make-a-qslider-change-with-double-values

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • P Offline
        P Offline
        pebal
        wrote on last edited by
        #3

        Set the minimum to 870 and maximum to 1070. Divide the value by 10 in slot.

        1 Reply Last reply
        3

        • Login

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