[PyQt] QDoubleSpinBox & it's precision
Hans-Peter Jansen
hpj at urpla.net
Fri Oct 9 08:38:29 BST 2009
Am Freitag 09 Oktober 2009 schrieb Prashant Saxena:
> Hi,
>
> This is regarding the precision in "QDoubleSpinBox". With out sub
> classing things were not working as I expected.
>
>
> class QxDoubleSpinBox(QtGui.QDoubleSpinBox):
> def __init__(self, parent=None, value=0.):
> QtGui.QDoubleSpinBox.__init__(self, parent)
> self.setRange(0., 1.)
> self.setValue(0.421)
> self.setSingleStep(0.001)
> self.setFixedWidth(70)
> self.setWrapping(True)
> self.setDecimals(3)
>
> def valueFromText(self, str):
> return FixedPoint(str, 3)
>
> def textFromValue(self, value):
> print "textFromValue = ", value
> return str(value)
>
>
> As soon as I start the application, here are the results printed:
>
>
> textFromValue = 0.42
> textFromValue = 0.42
> textFromValue = 0.42
> textFromValue = 0.0
> textFromValue = 1.0
> textFromValue = 0.42
> textFromValue = 0.42
>
>
> I have no idea what's going on here and why "textFromValue" is getting
> called so many times with values getting changed each time. I was hoping
> that sub classing will solve the problem of precision.
>
> How do I solve this?
>
> Prashant
>
> qt-sdk-win-opensource-2009.03.1.exe
> Python 2.6.3
> PyQt-Py2.6-gpl-4.6-1
> Win XP, 32 Bit
>
Prashant, both issues are missing an self-contained example, and while at
it, is it possible for you to send plain text mails?
Pete
More information about the PyQt
mailing list