[Solved] Truncate a “real” value in a Text field?
QML and Qt Quick
3
Posts
2
Posters
2.6k
Views
1
Watching
-
wrote on 7 Oct 2011, 07:41 last edited by
Hello there,
I got the follow code :
@property real compassValue : 3.1415927895412 Text { text: "<b>" + compassValue + "°</b>" }@
The fact is that I only want to display "3.14". Is there a way to troncate the value ?
Thx for any help !
-
wrote on 7 Oct 2011, 08:01 last edited by
QML can use JavaScript Math object. I found in Google this method:
@
property real compassValue : 3.1415927895412
Text {
text: "<b>" + Math.round(compassValue*100)/100 + "°</b>"
}
@ -
wrote on 7 Oct 2011, 08:07 last edited by
very nice, thanks :)
3/3