PDA

View Full Version : Problems creating a Slider



franco.amato
30th September 2008, 20:56
Hi to all,
I having some problems in creating a slider.
IOn brief this is the code I wrote:


QSlider *slider = new QSlider(Qt::Vertical);

// range between 0.0 = silent and 1.0 = full volume
slider->setRange(0, 10);

slider->setSingleStep(0.2f); //doesn't work. I only have 10 tick
slider->setPageStep(1);
slider->setTickInterval(1);
slider->setTickPosition(QSlider::TicksRight);
slider->setValue(5);

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

yuriry
30th September 2008, 21:58
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.

franco.amato
30th September 2008, 22:28
Thank you.
It works. And it's possible to don't show the ticks?

Best,
Franco

franco.amato
30th September 2008, 22:33
Sorry for the last post.
I didn't see the QSlider::setTicksPositio(NoTicks);

Regards,
Franco