[Solved] Truncate a “real” value in a Text field?
-
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 !
-
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>"
}
@ -
very nice, thanks :)