[Digikam-devel] KDE4 KDoubleNumInput -> QDoubleSpinBox ???

Marcel Wiesweg marcel.wiesweg at gmx.de
Tue Apr 22 16:46:56 BST 2008


> Perhaps it's the problem in my KDE4 port ?

Looks like a KDE bug:

Look at the code from knuminput.cpp (current trunk):
        // upcast to base type to get the minimum/maximum in int form:
        QDoubleSpinBox * spin = d->spin;
        int slmax = spin->maximum(); <-- What if maximum is 0.4? Slider's maximum is 0.
        int slmin = spin->minimum(); <-- same for this
        int slvalue = spin->value(); <--
        int slstep = spin->singleStep(); <-- Step 0.01? slstep is 0
...
            priv->m_slider = new QSlider(Qt::Horizontal, this);
            priv->m_slider->setMinimum(slmin);
            priv->m_slider->setMaximum(slmax);
            priv->m_slider->setSingleStep(slstep);
            priv->m_slider->setValue(slvalue);

Look at compilation warning:
/home/marcel/freshmeat/multimedia/kde4/src/KDE/kdelibs/kdeui/widgets/knuminput.cpp:834: warning: converting to 'int' from 'double'


Looking at the docs: QDoubleSpinBox::singleStep() is a double value, here converted to an int. 
Converting 0.01 to int results in 0. QSlider only takes integer arguments, so the ints need to be mapped to double.
 The code above is not suitable for ranges and steps in [0; 1],
has very bad results for [1; 10], and may begin to work in the hundreds.



More information about the Digikam-devel mailing list