Results 1 to 4 of 4

Thread: Problems creating a Slider

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    620
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problems creating a Slider

    Hi to all,
    I having some problems in creating a slider.
    IOn brief this is the code I wrote:

    Qt Code:
    1. QSlider *slider = new QSlider(Qt::Vertical);
    2.  
    3. // range between 0.0 = silent and 1.0 = full volume
    4. slider->setRange(0, 10);
    5.  
    6. slider->setSingleStep(0.2f); //doesn't work. I only have 10 tick
    7. slider->setPageStep(1);
    8. slider->setTickInterval(1);
    9. slider->setTickPosition(QSlider::TicksRight);
    10. slider->setValue(5);
    To copy to clipboard, switch view to plain text mode 

    I would have a range between 0 and 1 (float) so I divide /10
    Seems that the slider is discrete. I would have a fluid cursor movement. Is possible?
    I also would have more that 10 tick between the 2 ranges [0-10]. How can I do it?
    A last question: I don't understand very well the pageStep property. What does mean?
    Regards,
    Franco

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems creating a Slider

    You can setRange(0, 50), setSingleStep(1) and divide by 50 instead of 10 to get the step size of 0.02.

    To make the step even smaller you can setRange(0,1000), setSingleStep(1) and divide by 1000.

    pageStep defines how much internal counter changes when PgUp/PgDown are pressed.

    pageStep : int

    This property holds the page step.

    The larger of two natural steps that an abstract slider provides and typically corresponds to the user pressing PageUp or PageDown.

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    620
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems creating a Slider

    Thank you.
    It works. And it's possible to don't show the ticks?

    Best,
    Franco

  4. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    620
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems creating a Slider

    Sorry for the last post.
    I didn't see the QSlider::setTicksPositio(NoTicks);

    Regards,
    Franco

Similar Threads

  1. problems creating toolbar...(do see the attachment)!
    By sumit in forum Qt Programming
    Replies: 15
    Last Post: 10th September 2008, 11:23

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.