1 想要获得001 002 这样的数字
QString b=QString("%1").arg(i, 3, 10, QChar('0'));
QStringList list;
for(int i=0;i<128;i++)
{
list.append(QString("%1").arg(i, 3, 10, QChar('0')));
}
输出为
("000", "001", "002", "003", "004", "005", "006", "007"...<span style="font-family: Arial, Helvetica, sans-serif;">"120", "121", "122", "123", "124", "125", "126", "127")
2 3.456789转QString保留3位小数
double d = 3.123124;
QString s=QString::number(d,'f',3);
qDebug()<<s;
输出为:"3.123"