PDA

View Full Version : Number formatting



squidge
29th October 2009, 00:20
I know it doesn't take much to code something like this myself, but if Qt already has the functionality, it makes sense to use that rather than bloating my source code.

64-bit integer such as: 17753210880. I want it displayed as: 17,753,210,880. Does Qt support this already or do I have to write my own method? In which case I'm not sure whether the best way is mathematically or using QString to insert the commas...

jano_alex_es
29th October 2009, 09:13
I you want to display it, you'll need to convert it to QString.

So, when you convert it to QString, insert the commas :)

Ginsengelf
29th October 2009, 09:29
Hi, maybe QLocale::toString helps.

Ginsengelf

squidge
29th October 2009, 17:16
QLocale::toString sounds perfect. Seems it'll even decide on whether to use ',' or '.' depending on country.

RSX
29th October 2009, 19:16
How about http://doc.trolltech.com/4.5/qstring.html#number ?