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

Gilles Caulier caulier.gilles at gmail.com
Tue Apr 22 16:53:28 BST 2008


2008/4/22 Marcel Wiesweg <marcel.wiesweg at gmx.de>:
>
>  > 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.

You has right Marcel.

I fork your message to Laurent Montel to fix the problem in KDELibs.

Best

Gilles Caulier



More information about the Digikam-devel mailing list