PDA

View Full Version : Spinbox value doesn't decrease after the initial integer value is displayed.



babygal
28th July 2010, 10:14
Spinbox initial integer value is first defined . So for example the initial integer value is 3.


int integervalue;
intSpinBox = new QSpinBox;
QString integertostring;
integertostring= QString::number(integervalue);

intSpinBox ->setSpecialValueText(integertostring);

So the first initial integer value is displayed in the spinbox. For example : 3 .
Then using the spinbox , I click the down button, or, by pressing the down on
the keyboard, the value in the spinbox doesn't decrease at all as it should.
The value remains to be 3.(the value is supposed to decrease to 2.)
However, by clicking the up button, or pressing up on the keyboard can increase the
value in the spinbox but the increased value is incorrect.From value 3 it changes to 1 instead of 2.

What is wrong? How do I resolve this bug? SOS !

Vit Stepanek
28th July 2010, 11:02
I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

Additional note:

As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.

babygal
30th July 2010, 03:36
I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

Additional note:

As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.

I want to display integer from a variable . The initial integer value cannot be specified as it could be any value that is read from integervalue.So I can't use setValue().
SOS !

babygal
30th July 2010, 04:11
I assume you want to display an integer value only in the spinbox, right? Why do you put the value in using "setSpecialValueText"? Can't you just call "setValue"?
Look at http://doc.qt.nokia.com/4.6/qspinbox.html for more.

Additional note:

As far as I understand the documentation of "setSpecialValueText", setting this text you add a special text that's different than the type displayed. But the value is 0 behind the text, so increasing will give you 1 instead of 2 no matter which value the added text contains.

The value doesn't decrease at all when the spinbox down button is clicked.It must be because the value behind is always '0' . How can I change its behaviour?

ChrisW67
30th July 2010, 06:02
Read the documentation. QSpinBox::setValue() is exactly what you want to set the value displayed by the spin box and also the value that is affected by the up/down controls. Get the current value back with value().

QSpinBox::setSpecialValueText() specifies what the spin box should display when its value equals the minimum() allowable value, e.g. use it if you want the spin box to display "It's zero dude" instead of the integer value when the value == minimum().

babygal
4th August 2010, 05:06
SOLVED! Thank you. Use QSpinBox::setValue() and problem solved.




Read the documentation. QSpinBox::setValue() is exactly what you want to set the value displayed by the spin box and also the value that is affected by the up/down controls. Get the current value back with value().

QSpinBox::setSpecialValueText() specifies what the spin box should display when its value equals the minimum() allowable value, e.g. use it if you want the spin box to display "It's zero dude" instead of the integer value when the value == minimum().