I'm using pyqt and have two QDoubleSpinBoxes which I use to define intervals. Typically those intervals are integer, e.g. degree Celsius. Depending on the use case I switch the range, stepsize, unit, etc. One case involves voltage and needs to be decimal, so I always use QDoubleSpinBox but reduce decimals and stepsize to correspond to integers. Here is a snippet for the voltage case:
self.to_spin.setDecimals(2)
self.from_spin.setDecimals(2)
self.to_spin.setSuffix(" V")
self.from_spin.setSuffix(" V")
self.to_spin.setSingleStep(0.1)
self.from_spin.setSingleStep(0.1)
self.to_spin.setRange(0.0,40.0)
self.from_spin.setRange(0.0,40.0)
if set_defaults:
self.from_spin.setValue(2.0)
self.to_spin.setValue(18.0)
The Problem is, that even in the Scenario above the values entered are always corrected to the nearest integer. I use QDoubleSpinBoxes in a different place but without varying the intervals, etc. and there it is working as it should be.
Any suggestions? The validator should be okay because it's a DoubleBox, right? Any help is appreciated - thanks in advance,
Ben