Results 1 to 7 of 7

Thread: QwtSlider with zero range

  1. #1
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QwtSlider with zero range

    Hi,

    this may sound strange, but I have a use case where one can set the range of a QwtSlider i.e. to (50.0, 50.0). This is meant to nail a variable to a fixed value.
    As far as I understood the code, QwtAbstractScale::rescale() is called when borders are set and if upperBorder == lowerBorder, it seems the value is set to 0. My first idea was to reimplement QwtAbstractScale::rescale(), but this function isn't virtual. The drawing part is not important in my case, I do not use drawn scales.
    Did I understand anything wrong or is there a way to get around this behaviour? Or do I have to build some wrapper around QwtSlider to catch this case?

    Thanks in advance,
    Carsten

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

    Default Re: QwtSlider with zero range

    What about slider->setReadOnly( true ) ?

    Uwe

  3. #3
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtSlider with zero range

    Uwe,

    thanks for your answer.
    The borders of the slider are changed @runtime. At the moment the borders are set, rescale() is called. So it doesn't help to make it read only. The basic problem is that the value of the slider is set to 0 if borders have the same value.

    Best regards,
    Carsten

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

    Default Re: QwtSlider with zero range

    Thought you want to nail a fixed value - why do you have to narrow the borders for this ?
    But anyway: a slider with an empty range doesn't make any sense as you don't have a slider position then.

    Uwe

  5. #5
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtSlider with zero range

    Ok, to give a more complete explanation: our machines are able to pulse some light with a frequency. The frequency can be adjusted by the user in a specific range, set by our service personal. There are some machines which should pulse only on a single frequency, so our service is used to set upper border and lower border to the same value.

    Anyway, I had the same use case with Qwt5.2.1, and it worked there (setting upper border and lower border to let's say 50 and slider->value() gives me 50). The behaviour in Qwt6.1.2 is different, slider->value() gives me 0. The range is not empty (may depend on the definition of empty of course), and I think there is a position for the thumb - 50. Even if the thumb cannot move.

    Hopefully this explains my problem better. Sorry for the confusion!

    Thanks,
    Carsten

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

    Default Re: QwtSlider with zero range

    Each position of a slider corresponds to a value, and each value to a position - otherwise it doesn't work. So what should happen when all positions of the slider correspond to 50 - where to draw the handle ?
    But why not simply setting some valid range and putting the slider into read only mode, when the user sets an empty range ?

    Uwe

  7. #7
    Join Date
    Apr 2014
    Posts
    13
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtSlider with zero range

    I implemented it as you suggested, it works fine.
    Thanks for your help,
    Carsten

Similar Threads

  1. Customizing Qwtslider
    By Navi in forum Qwt
    Replies: 2
    Last Post: 24th June 2015, 08:08
  2. Customizing Qwtslider
    By Navi in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2015, 15:34
  3. scale in QwtSlider and QwtPlot
    By mastupristi in forum Qwt
    Replies: 3
    Last Post: 20th October 2014, 07:37
  4. QwtSlider stepSize
    By snowbound in forum Qwt
    Replies: 5
    Last Post: 14th March 2014, 13:46
  5. QwtSlider resize
    By vratojr in forum Qwt
    Replies: 1
    Last Post: 13th July 2011, 12:28

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.