本人的嵌入式职业英文记录 - 第1周

来源:互联网 发布:国家质检总局网络培训 编辑:程序博客网 时间:2024/06/04 19:34

时间:2016/10/31 - 2016/11/06


单词来源学习(出处):

属于:Qt中的类QString的方法number格式举例讲解:

例句:

QString QString::number ( double n, char format = 'g', int precision = 6 ) [static]

Returns a string equivalent(1) of the number n, formatted according to the specified format and precision. See Argument Formats for details.

Argument Formats

翻译:返回一个字符串的数字n,格式化按照指定的格式和精度。有关详细信息,请参阅参数格式。

参数格式

In member functions where an argument format can be specified (e.g., arg(), number()), the argument format can be one of the following:

解释:在成员函数可以指定一个参数格式(如。arg(),()),参数的格式可以是下列之一:


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

 解释:用G,E,f格式,无论是哪一个,都是最简洁的;


A precision(2) is also specified(3) with the argument format. For the 'e', 'E', and 'f' formats, the precision represents the number of digits(4) after the decimal point. For the 'g' and 'G' formats, the precision represents the maximum number of significant digits (trailing(5) zeroes are omitted(6)).

解释:精度也是指定的参数格式。对于“e”E”“f”格式,精度表示小数点后的数。‘g’G’格式、精度表示有效数字的最大数(落后于0省略)

单词收集:

1.equivalent  

 [ɪ'kwɪv(ə)l(ə)nt]  美 [ɪ'kwɪvələnt] 

n. 等价物,相等物

2.precision

  [prɪ'sɪʒ(ə)n]   [prɪ'sɪʒn]  

n. 精度,[精密度;精确

adj. 精密的,精确的

3.specified:原型为specify

  ['spesɪfaɪ]   ['spɛsɪfaɪ]  

vt. 指定;详细说明;列举;把列入说明书

4.digit

  ['dɪdʒɪt]   ['dɪdʒɪt] 

n. 数字;手指或足趾;一指宽

5.trailing:原型为trail

  [treɪl]   [trel]

 vt. 追踪;拖;蔓延;落后于

n. 小径;痕迹;尾部;踪迹;一串,一系列

vi. 飘出;蔓生;垂下;拖曳

n. (Trail)人名;()特雷尔

6.omitted:原型为omit

  [ə(ʊ)'mɪt]   [ə'mɪt] 

vt. 省略;遗漏;删除;疏忽

知识点收集:

这里的number方法的格式为:

QString QString::number ( double n, char format = 'g', int precision = 6 ) [static]

第一个参数为提取的数字,第二个参数为输出的格式,第三个参数为提取的数小数点后保留的位数;

例子:

int data;

ui->lbl_time_hour->setText(QString::number(data,'f',0));

作用:设置ui界面的lbl_time_hour控件为data,设置精确度为‘f’,设置输出的值小数点后面没有数,为整数;

0 0