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

LengthUnit str2unit(const QString &iUnitStr)
QString unit2str(LengthUnit iUnit)

Detailed Description

TLength 长度类。 用于处理各种长度单位之间的互相转换。 目前支持的单位如下:

pmpicometre皮米
nmnanometre纳米
ummicrometre微米
mmmillimetre毫米
cmcentimetre厘米
dmdecimetre分米
mmetre
damdecameter公丈
hmhectoametre
kmkilometre公里
nminautical mile海里
ftfoot英尺
ininch英寸
milmil千分之一英寸
ydyard
mimile英里
auastronomical unit天文单位
lylight year光年
pcparsec秒差距

用法


  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 Type Documentation

enum TLength::LengthUnit

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.