PDA

View Full Version : Is It possible to show zeros numbers after decimal point in a QLabel?



emmaperea
6th July 2016, 15:54
Hello, this is my first question in this forum, sorry if I make a mistake.
Im using a QLabel to show float numbers, that is working, my problem is that I want to show ever two numbers after the decimal point. eg If the number is 1.55 shows 1.55, but whe the numer is 1.50 shows 1.5 and I want to show 1.50 or if the number is 1.00 shows 1 and I want to show 1.00.
I am using setNum(number) to show the value.
Any suggestion? anywone can help me?
Thanks

jefftee
6th July 2016, 17:04
Doesn't QString::number with the 'g' format specifier do what you want?

Edit: Sorry, misread your post, you want the format specifier 'f' with precision of 2.

jimbo
6th July 2016, 17:10
http://www.qtforum.org/article/29565/output-a-double-to-only-2-decimal-points.html

emmaperea
15th July 2016, 19:18
http://www.qtforum.org/article/29565/output-a-double-to-only-2-decimal-points.html

Yes i coul resolve it, thanks for you reply

Thank you, i could resolve it