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

本文详细介绍了Qt中QString类的number静态方法,包括如何使用不同的格式化选项来显示数字,以及如何指定精度来控制小数点后的位数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

时间: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’,设置输出的值小数点后面没有数,为整数;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值