Pages
API Documentation
On this page

KUnitConversion::Unit Class

Class to define a unit of measurement. More...

  • Header: #include <Unit>
  • CMake: find_package(KF6 REQUIRED COMPONENTS UnitConversion)
    target_link_libraries(mytarget PRIVATE KF6::UnitConversion)

List of all members, including inherited members

Public Functions

Detailed Description

This is a class to define a unit of measurement.

See also Converter, UnitCategory, Value

Member Function Documentation

Unit::Unit()

Null constructor

KUnitConversion::UnitCategory Unit::category() const

Returns unit category.

KUnitConversion::CategoryId Unit::categoryId() const

Returns category id.

QString Unit::description() const

Returns translated name for unit.

KUnitConversion::UnitId Unit::id() const

Returns unit id.

bool Unit::isNull() const

Returns returns true if this Unit is null

bool Unit::isValid() const

Returns if unit is valid.

QString Unit::symbol() const

Returns symbol for the unit.

QString Unit::toString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const

value number value

fieldWidth width of the formatted field, padded by spaces. Positive value aligns right, negative aligns left

format type of floating point formatting, like in QString::arg

precision number of digits after the decimal separator

fillChar the character used to fill up the empty places when field width is greater than argument width

Returns value + unit string

QString Unit::toSymbolString(qreal value, int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const

value number value

fieldWidth width of the formatted field, padded by spaces. Positive value aligns right, negative aligns left

format type of floating point formatting, like in QString::arg

precision number of digits after the decimal separator

fillChar the character used to fill up the empty places when field width is greater than argument width

Returns value + unit string

bool Unit::operator==(const KUnitConversion::Unit &other) const

Returns true if this Unit is equal to the other Unit.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.