KUnitConversion::Value Class
class KUnitConversion::ValueClass to hold a value in a unit of measurement. More...
Header: | #include <Value> |
CMake: | find_package(KF6 REQUIRED COMPONENTS UnitConversion) target_link_libraries(mytarget PRIVATE KF6::UnitConversion) |
Public Functions
Value() | |
Value(const QVariant &number, const QString &unitString) | |
Value(qreal number, KUnitConversion::UnitId unitId) | |
Value(qreal number, const KUnitConversion::Unit &unit) | |
Value(qreal number, const QString &unitString) | |
KUnitConversion::Value | convertTo(KUnitConversion::UnitId unit) const |
KUnitConversion::Value | convertTo(const KUnitConversion::Unit &unit) const |
KUnitConversion::Value | convertTo(const QString &unit) const |
bool | isNull() const |
bool | isValid() const |
qreal | number() const |
KUnitConversion::Value & | round(uint decimals) |
QString | toString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const |
QString | toSymbolString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const |
KUnitConversion::Unit | unit() const |
bool | operator==(const KUnitConversion::Value &other) const |
Detailed Description
This is a class to hold a value in a unit of measurement.
See also Converter, Unit, and UnitCategory.
Member Function Documentation
Value::Value()
Creates a null value.
Value::Value(const QVariant &number, const QString &unitString)
Creates a value based on a QVariant (calling toReal() on it) with a unit (as a string).
Value::Value(qreal number, KUnitConversion::UnitId unitId)
Creates a value with a unit (as a enum value).
Value::Value(qreal number, const KUnitConversion::Unit &unit)
Creates a value with a unit instance
Value::Value(qreal number, const QString &unitString)
Creates a value with a unit (as a string).
KUnitConversion::Value Value::convertTo(KUnitConversion::UnitId unit) const
Convert to another unit
KUnitConversion::Value Value::convertTo(const KUnitConversion::Unit &unit) const
Convert to another unit
KUnitConversion::Value Value::convertTo(const QString &unit) const
Convert to another unit
bool Value::isNull() const
Returns returns true if this Value is null
bool Value::isValid() const
Returns true if value is valid
qreal Value::number() const
Number part of the value
KUnitConversion::Value &Value::round(uint decimals)
Rounds value to decimal count
decimals decimal count.
QString Value::toString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const
Convert value to a string
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 as a string
QString Value::toSymbolString(int fieldWidth = 0, char format = 'g', int precision = -1, const QChar &fillChar = QLatin1Char(' ')) const
Convert value to a string with symbol
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 as a string
KUnitConversion::Unit Value::unit() const
Unit part of the value
bool Value::operator==(const KUnitConversion::Value &other) const
Returns true if this Value is equal to the other Value.