tags:

views:

89

answers:

2

I am using a QDoubleSpinBox,

And during sometime, I have a range where min and max is less than 1 and greater than 0. If I set that range, when I hit the step down the value in the spin box changes to 0.0 and step up would result in 1.0 eventhough they are out of range. I would like to know if there is a particular way to avoid this problem.

Regards, Arjun

+2  A: 

Use setSingleStep() to set the step size to something reasonable for your range. (http://doc.trolltech.com/4.5/qdoublespinbox.html#singleStep-prop)

Parker
+1  A: 

As Parker said, you need to use setSingleStep() so that you do not increment by 1.0.

More to the point though, there is no support for "exclusive" ranges, i.e., you cannot give a range 0 to 1.0 unless you want to be able to use the values 0 and 1.0 as well.

Instead, once you have decided on your step size, you could potentially set your min and max like this:

minimum = exclusive_minimum + step_size
maximum = exclusive_maximum - step_size

However this could be undesirable since the user can choose values between the step sizes by typing directly into the spin box. So a better solution is to choose how many decimal places the spinbox should be accurate to, and set the minimum and maximum to the smallest and largest numbers nearest the exclusive_minimum and exclusive_maximum values.

For example, if exclusive_minimum is 0.0 and exclusive_maximum is 1.0, and you are accurate to five decimal places, then set minimum to 0.00001 and maximum to 0.99999.

Chris Cameron