'Qdoublespinbox does not allow values less than 1
Qdoublespinbox does not allow values less than 1, decimal values with precision grater than 1, values in positive range 0.00 - 0.99 (for example). There is no problem with setting it´s value to 1.1, 1.11, 1,04, but not 0.5 .... it is rounding up anyway to 1.
I have tried setting range to negative values with precision, setting explicitly the numbers of decimals and the minimum value of the widget, but all for nothing.
Solution 1:[1]
You can have a look at the Spin Boxes Example (accessible through QtCreator/Welcome/Examples or https://doc.qt.io/qt-5/qtwidgets-widgets-spinboxes-example.html).
You can have float or double precision rounding issues if you get your values from a calculation with not enough precision in memory.
You can also force the local to accept dot as decimal separator as you seem to mix comma and dot: add QLocale::setDefault(QLocale::C);
at the beginning of your program. You can also create a custom double validator to accept both dot and comma by inheriting QDoubleValidator.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | kaloskagatos |