Ashif
Ashif

Reputation: 1684

How to get steps and current value, after clicking on up/down control of QDoubleSpinBox?

My question is, how can I get the control of stepSize and "currentvalue" before "value" in the spinbox(I required double spinbox (QDoubleSpinBox)) gets incremented/decremented ?

Note: I know, "valueChanged" signal is there but, slot gets called only after currentvalue incremented/decremented

Upvotes: 0

Views: 672

Answers (1)

Marek R
Marek R

Reputation: 37512

In second comment I'm pointing out that you misunderstand functionality of QAbstractSpinBox::stepBy.

So when you subclass QDoubleSpinBox you can do it like that:

void SubclassOfDoubleSpinBox::stepBy(int steps) {
    if (steps>0) {
       if (steps>=10) { // note some events call stepBy with step value 10 or -10
           setSingleStep(incrementStep10());
       } else {
           setSingleStep(incrementStep1());
       }
    } else {
       if (steps<=-10) {
           setSingleStep(decrementStep10());
       } else {
           setSingleStep(decrementStep1());
       }
    }

    QDoubleSpinBox::stepBy(steps);
}

this will do the job with logarithmic increment decrement logic.

Upvotes: 1

Related Questions