PDA

View Full Version : Hide the decimals in QDoubleSpinBox



vinodpaul
24th August 2011, 12:31
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

high_flyer
24th August 2011, 12:33
Try calling setDecimals() with '0' when the you only have 0's after the decimal point, and with 2 otherwise.

vinodpaul
25th August 2011, 05:24
67946793Hi 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 .

wysota
25th August 2011, 07:31
Subclass and reimplement textFromValue().