DAbstractUnitFormatter 类是对拥有相同类型数据管理的接口类.
更多...
|
virtual int | unitMax () const =0 |
| 返回列表中最大的单位. 更多...
|
|
virtual int | unitMin () const =0 |
| 返回列表中最小的单位. 更多...
|
|
virtual uint | unitConvertRate (int unitId) const =0 |
| 返回当前设置的转换单位. unitId 单元ID. 更多...
|
|
virtual qreal | unitValueMax (int unitId) const |
| 返回列表中根据当前设置的转换单位的最大值. unitId 单元ID.
|
|
virtual qreal | unitValueMin (int unitId) const |
| 返回列表中根据当前设置的转换单位的最小值. unitId 单元ID.
|
|
virtual QString | unitStr (int unitId) const =0 |
| 传入id,返回列表中对应的字符串. unitId 单元ID. 更多...
|
|
DAbstractUnitFormatter 类是对拥有相同类型数据管理的接口类.
\inmodule dtkcore
接口定义了最大值、最小值、转换单位和单位对应的字符串。
◆ format()
QPair< qreal, int > Dtk::Core::DAbstractUnitFormatter::format |
( |
const qreal |
value, |
|
|
const int |
unit |
|
) |
| const |
将值转换到最合适的单位上
如果值大于 unitMin() 或者小于 unitMax() ,会尽量保证值被转换到接近最小值的合适单位上。
value 原始数值 unit 当前的转换单位
- 返回
- QPair<qreal, int> 转换过的数值和转化单位
◆ formatAs()
qreal Dtk::Core::DAbstractUnitFormatter::formatAs |
( |
qreal |
value, |
|
|
int |
currentUnit, |
|
|
const int |
targetUnit |
|
) |
| const |
将传入的值从当前转换单位转换到目标单位上,返回转换过的值 如果当前转换单位小于目标单位,值会被缩小,反之会放大,当前转换单位也会被缩小和放大,直至当前转换单位等于目标单位。
value 原始数值 currentUnit 当前的转换比率 targetUnit 目标的转换比率
- 返回
- qreal 返回转换过的值
◆ formatAsUnitList()
QList< QPair< qreal, int > > Dtk::Core::DAbstractUnitFormatter::formatAsUnitList |
( |
const qreal |
value, |
|
|
int |
unit |
|
) |
| const |
是 format() ,但是包含了完整的转换数据
value unit
- 返回
- QList<QPair<qreal, int> >
◆ unitConvertRate()
uint Dtk::Core::DAbstractUnitFormatter::unitConvertRate |
( |
int |
unitId | ) |
const |
|
protectedpure virtual |
◆ unitMax()
int Dtk::Core::DAbstractUnitFormatter::unitMax |
( |
| ) |
const |
|
protectedpure virtual |
◆ unitMin()
int Dtk::Core::DAbstractUnitFormatter::unitMin |
( |
| ) |
const |
|
protectedpure virtual |
◆ unitStr()
QString Dtk::Core::DAbstractUnitFormatter::unitStr |
( |
int |
unitId | ) |
const |
|
protectedpure virtual |
该类的文档由以下文件生成: