cpp-example icon indicating copy to clipboard operation
cpp-example copied to clipboard

about lineEdit

Open stephensyn opened this issue 5 years ago • 4 comments

问题: LineEdit通过QDataWidgetMapper绑定了数据,希望显示的数据格式保留2位小数。比如500.00 ` dataMap = new QDataWidgetMapper; //给QDataWidgetMapper加载数据源 dataMap->setModel(repair_filter_model);

dataMap->addMapping(ui->lineEdit_Amount, 11);`

stephensyn avatar Apr 03 '20 15:04 stephensyn

What is your ask?

shelllet avatar Apr 10 '20 00:04 shelllet

谢谢!

stephensyn avatar Apr 18 '20 10:04 stephensyn

我是这样做的。感觉好像有点LOW。还有别的方法吗? void ComplexPocess::on_lineEdit_Amount_textChanged(const QString &arg1) { ui->lineEdit_Amount->blockSignals(true); ui->lineEdit_Amount->setText(QString::number(arg1.toDouble(), 'f', 2)); ui->lineEdit_Amount->blockSignals(false); }

stephensyn avatar Apr 18 '20 15:04 stephensyn

LineEdit 添加验证器,或者inputMask是比较好的方式

shelllet avatar Jun 29 '20 07:06 shelllet