Hide the decimals in QDoubleSpinBox
Hi,
Is it possible to hide decimals in QDoubleSpinBox if the values after the decimal are just zeros and show the decimal if the values are non zero. If the values after the decimal points are non zero then the precision should be 2.
Thanks in advance
Re: Hide the decimals in QDoubleSpinBox
Try calling setDecimals() with '0' when the you only have 0's after the decimal point, and with 2 otherwise.
2 Attachment(s)
Re: Hide the decimals in QDoubleSpinBox
Attachment 6794Attachment 6793Hi high_flyer , But if we setDecimals() with '0' ,then we won't be able to insert decimals if we want. The actual problem is that I have created a doubespinbox with dimension height 20 and width 45, but the numbers with precision 2 is not clearly visible within that box, and I cannot increase the box width also. I need to show the numbers clearly without increasing the width of the box. While changing the value of the spinbox, I noticed that the cursor position is changing from first position to last position and again back to first position alternatively. If the position of the cursor is after the number(2nd picture) then the number won't be shown properly.Is there any method by which I can keep the cursor at the first position itself .
Re: Hide the decimals in QDoubleSpinBox
Subclass and reimplement textFromValue().