小数点模式

输入的数字默认被赋予小数点,保持数据格式统一,显示起来美观


强制小数点模式

强制显示两位小数 x.xx

  1. TextField {
  2. id: textField
  3. placeholderText: qsTr("Text Field")
  4. onAccepted:(
  5. text = (text*100/100).toFixed(2),
  6. console.log(text)
  7. )
  8. }

使用 text*100/100 强制输入值变为小数
使用js函数 toFixed(2) 来控制小数点位为 2