Qt如何向文本框添加数字及显示提示 - Qt学习

       运用 QString::arg() 函数,可以向Qt中的各类控件和文本框中添加需要显示的数字变量,实现了数字的格式化显示。调用控件成员函数 setStatusTip() 设置提示信息。

格式化添加数字

       比如要向QLineEdit类对象中格式化添加数字,使用如下代码即可

ui->lineEdit->setText(tr("Enter the message %1 %2").arg(5).arg(6));
ui->lineEdit->setStatusTip(tr("Enter the message %1 %2").arg(3).arg(4));

测试结果

猜你喜欢

转载自blog.csdn.net/yishuicanhong/article/details/80958262