http://blog.youkuaiyun.com/gdizcm/article/details/54728381
QString 保留小数点后一位。
double num;
QString::number(num,'f',1)); //保留几位1就改成几
[static] QString QString::number(double n, char format = 'g', int precision = 6)
The argument format can be one of the following:
Format | Meaning |
---|---|
e | format as [-]9.9e[+|-]999 |
E | format as [-]9.9E[+|-]999 |
f | format as [-]9.9 |
g | use e or f format, whichever is the most concise |
G | use E or f format, whichever is the most concise |
int 转16进制QString并补零
int vibID;
QString key = QString("%1").arg(vibID, 8, 16, QLatin1Char('0')); //8代表宽度,16表示16进制,空位补零
QString QString::arg(int a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char( ' ' )) const