Results 1 to 6 of 6

Thread: QwtSlider stepSize

  1. #1
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtSlider stepSize

    I have a QwtSlider, the range varies but typical would be 0 - 1000. With scaleMaxMajor() it labels every 200 which is good.

    I need the slider to snap to the nearest 10, If I do setScaleStepSize(10) the snapping works but major ticks are labelled ever 10 units.

    How do I set the step size without messing up the labels?

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtSlider stepSize

    What major ticks do you want to see for which range ?

    Uwe

  3. #3
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtSlider stepSize

    Major ticks in the same place as the labels. So labels and major ticks every 200, no minor ticks and the slider snapping every 10.

    It doesn't need to be exactly 200, that's just an example. I want a reasonable number of major ticks and labels, like 5 or 6.
    Last edited by snowbound; 14th March 2014 at 12:38.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtSlider stepSize

    Major ticks in the same place as the labels.
    What is always the case: labels are painted at major ticks by definition.

    It doesn't need to be exactly 200, that's just an example. I want a reasonable number of major ticks and labels, like 5 or 6.
    These are contradictory statements - you can control the step size or the number of steps, not both.

    Uwe

  5. #5
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtSlider stepSize

    What I'm trying to achieve in 6.1 is the lower right horizontal slider in the example project from 6.0. The one that goes from 1000 to 3000, has major labels every 500 and the slider step size is 10.

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtSlider stepSize

    Scale and step sizes have been decoupled because of non linear ( f.e. logarithmic ) scales - what is a new feature of Qwt 6.1

    For controlling the major ticks see: QwtAbstractScale::setScaleMaxMajor( int ), but the default setting of 8 should be o.k. Remove all what you tried so far and simply do a "slider->setScale( 1000, 3000);"
    For controlling the number of steps have a look at the methods in QwtAbstractSlider. In case of a linear scale you can calculate the number of steps easily this way: numSteps = ( max - min ) / stepSize;

    Uwe

  7. The following user says thank you to Uwe for this useful post:

    snowbound (14th March 2014)

Similar Threads

  1. Replies: 3
    Last Post: 15th January 2014, 07:52
  2. Customize tick labels in a QwtSlider
    By RomanRdgz in forum Qwt
    Replies: 16
    Last Post: 10th September 2012, 13:02
  3. QwtSlider resize
    By vratojr in forum Qwt
    Replies: 1
    Last Post: 13th July 2011, 12:28
  4. Align QwtSlider and QwtPlot
    By justoit in forum Qwt
    Replies: 4
    Last Post: 4th May 2011, 11:41
  5. Setting Initial QwtSlider Position
    By Mannion in forum Qwt
    Replies: 4
    Last Post: 3rd May 2011, 21:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.