Solved how to decrement spinbox values.
-
@Leopold
so is the minimum range set to allow for negative values? -
Hello,
I don't want negative values, i want to decrement.
spinBox = 0.
m_ui->spinBox-> setValue(m_ui->spinBox-> value()+1)
spiBox=1
m_ui->spinBox-> setValue(m_ui->spinBox-> value()+1)
spinBox=2
m_ui->spinBox-> setValue(m_ui->spinBox-> value()-1)
spinBox stays at 2 should become 1 -
@Leopold
Your code looks fine, so it must be something else.... -
Hi
I agree with @JonB . That should just work.
Did you trym_ui->spinBox-> setValue(1); m_ui->spinBox-> setValue(2); m_ui->spinBox-> setValue(1);
-
@Leopold yes, i see. as the others say the code looks correct so i was just fishing :-)
-
@mrjj
yes, direct settings work,
increment is good too but decrement with:
m_ui->spinBox-> setValue(m_ui->spinBox-> value()-1)
spinBox stays at 2 should become 1
is not working.
Any an other idea for decrementing by 1 step?
Decrementing by arrows is possible so it should be possible by code too. -
Hi
Try to do it outside a slot.
I think its related to the event loop and how you trigger setValue slot.
Setting the values directly works so it must drop a setValue or something
like that. -
Are you perhaps handling the spinbox valueChanged() signal and inadvertently blocking the new value ?
-
Sorry for bothering,
the code works,it was my fault within an if else.
first i incremented,then i decremented so it looked as if nothing had happened. -
@Leopold is your issue solved? If so, please don't forget to mark your post as such. Thanks.