Gui*_*shy 0 floating-point qt text qml
我得到了以下代码:
property real compassValue : 3.1415927895412
Text {
text: "<b>" + compassValue + "°</b>"
}
Run Code Online (Sandbox Code Playgroud)
事实是我只想显示"3.14".有没有办法截断这个值?
你可以简单地使用这个toFixed()功能:
property real compassValue : 3.1415927895412
Text {
text: "<b>" + compassValue.toFixed(2) + "°</b>"
}
Run Code Online (Sandbox Code Playgroud)