TLength Class
TLength 长度类。 用于处理各种长度单位之间的互相转换。 目前支持的单位如下: More...
| Header: | #include <TLength> |
Public Types
| enum | LengthUnit { None, PM, NM, UM, ..., PC } |
Public Functions
| TLength() | |
| TLength(double iValue, LengthUnit iUnit) | |
| TLength(double iValue, const QString &iUnit) | |
| TLength(const TLength &iOther) | |
| ~TLength() | |
| TLength & | round(int iPrecision) |
| void | setUnit(LengthUnit iUnit) |
| void | setValue(double iValue) |
| QString | str() const |
| TLength & | to(const QString &iUnit) |
| TLength & | to(LengthUnit iUnit) |
| LengthUnit | unit() const |
| double | value() const |
| TLength & | operator=(const TLength &iOther) |
Static Public Members
Detailed Description
TLength 长度类。 用于处理各种长度单位之间的互相转换。 目前支持的单位如下:
| pm | picometre | 皮米 |
| nm | nanometre | 纳米 |
| um | micrometre | 微米 |
| mm | millimetre | 毫米 |
| cm | centimetre | 厘米 |
| dm | decimetre | 分米 |
| m | metre | 米 |
| dam | decameter | 公丈 |
| hm | hectoametre | 粨 |
| km | kilometre | 公里 |
| nmi | nautical mile | 海里 |
| ft | foot | 英尺 |
| in | inch | 英寸 |
| mil | mil | 千分之一英寸 |
| yd | yard | 码 |
| mi | mile | 英里 |
| au | astronomical unit | 天文单位 |
| ly | light year | 光年 |
| pc | parsec | 秒差距 |
用法
TLength(2.56, TLength::MIL).to(TLength::MM).round(3).value(); // 0.065 TLength(2.56, TLength::MIL).to(TLength::MM).round(3).str(); // 0.065mm
Member Function Documentation
TLength::TLength()
Default constructs an instance of TLength.
TLength::TLength(double iValue, LengthUnit iUnit)
Default constructs an instance of TLength.
TLength::TLength(double iValue, const QString &iUnit)
Default constructs an instance of TLength.
TLength::TLength(const TLength &iOther)
Copy constructor.
TLength::~TLength()
Destroys the instance of TLength.
TLength &TLength::round(int iPrecision)
void TLength::setUnit(LengthUnit iUnit)
See also unit().
void TLength::setValue(double iValue)
See also value().
QString TLength::str() const
[static] LengthUnit TLength::str2unit(const QString &iUnitStr)
TLength &TLength::to(const QString &iUnit)
TLength &TLength::to(LengthUnit iUnit)
LengthUnit TLength::unit() const
See also setUnit().
[static] QString TLength::unit2str(LengthUnit iUnit)
double TLength::value() const
See also setValue().
TLength &TLength::operator=(const TLength &iOther)
Copy-assignment operator.