Functions | |
QString | qtlHtmlLink (const QString &link, const QString &text) |
Build an HTML string containing a link to a URL. More... | |
QString | qtlSecondsToString (int seconds) |
Format a duration into a string. More... | |
QString | qtlSizeToString (qlonglong value, int maxDecimalDigits, bool useBinaryUnits, const QString &unitName) |
Format a size into a human-friendly string. More... | |
QString | qtlStringSpace (const QString &str, int groupSize, Qt::LayoutDirection direction, const QString &space) |
Insert spaces at regular intervals in a string. More... | |
float | qtlToFloat (const QString &str, float def) |
Convert a string into a float. More... | |
int | qtlToInt (const QString &str, int def, int min, int max, int base) |
Convert a string into an integer. More... | |
qint64 | qtlToInt64 (const QString &str, qint64 def, qint64 min, qint64 max, int base) |
Convert a string into a 64-bit integer. More... | |
quint32 | qtlToUInt32 (const QString &str, quint32 def, quint32 min, quint32 max, int base) |
Convert a string into a 32-bit unsigned integer. More... | |
quint64 | qtlToUInt64 (const QString &str, quint64 def, quint64 min, quint64 max, int base) |
Convert a string into a 64-bit unsigned integer. More... | |
QVector< wchar_t > | qtlToWCharVector (const QString &str) |
Convert a QString into a null-terminated vector of wchar_t. More... | |
int qtlToInt | ( | const QString & | str, |
int | def = -1 , |
||
int | min = 0 , |
||
int | max = INT_MAX , |
||
int | base = 10 |
||
) |
Convert a string into an integer.
[in] | str | String to convert. |
[in] | def | Value to return if str is not a valid int in the range min to max. |
[in] | min | Minimum allowed value. |
[in] | max | Maximum allowed value. |
[in] | base | Base for conversion, 10 by default, must be between 2 and 36, or 0. If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used. |
quint32 qtlToUInt32 | ( | const QString & | str, |
quint32 | def = 0xFFFFFFFFU , |
||
quint32 | min = 0 , |
||
quint32 | max = 0xFFFFFFFFU , |
||
int | base = 10 |
||
) |
Convert a string into a 32-bit unsigned integer.
[in] | str | String to convert. |
[in] | def | Value to return if str is not a valid int in the range min to max. |
[in] | min | Minimum allowed value. |
[in] | max | Maximum allowed value. |
[in] | base | Base for conversion, 10 by default, must be between 2 and 36, or 0. If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used. |
qint64 qtlToInt64 | ( | const QString & | str, |
qint64 | def = -1 , |
||
qint64 | min = 0 , |
||
qint64 | max = Q_INT64_C(0x7FFFFFFFFFFFFFFF) , |
||
int | base = 10 |
||
) |
Convert a string into a 64-bit integer.
[in] | str | String to convert. |
[in] | def | Value to return if str is not a valid int in the range min to max. |
[in] | min | Minimum allowed value. |
[in] | max | Maximum allowed value. |
[in] | base | Base for conversion, 10 by default, must be between 2 and 36, or 0. If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used. |
quint64 qtlToUInt64 | ( | const QString & | str, |
quint64 | def = Q_UINT64_C(0xFFFFFFFFFFFFFFFF) , |
||
quint64 | min = 0 , |
||
quint64 | max = Q_INT64_C(0xFFFFFFFFFFFFFFFF) , |
||
int | base = 10 |
||
) |
Convert a string into a 64-bit unsigned integer.
[in] | str | String to convert. |
[in] | def | Value to return if str is not a valid int in the range min to max. |
[in] | min | Minimum allowed value. |
[in] | max | Maximum allowed value. |
[in] | base | Base for conversion, 10 by default, must be between 2 and 36, or 0. If base is 0, the C language convention is used: If the string begins with "0x", base 16 is used; if the string begins with "0", base 8 is used; otherwise, base 10 is used. |
float qtlToFloat | ( | const QString & | str, |
float | def = 0.0 |
||
) |
Convert a string into a float.
Syntax like "x/y" and "x:y" are interpreted as rational numbers.
[in] | str | String to convert. |
[in] | def | Value to return if str is not a valid float. |
QString qtlSecondsToString | ( | int | seconds | ) |
Format a duration into a string.
[in] | seconds | Duration in seconds. |
QString qtlStringSpace | ( | const QString & | str, |
int | groupSize, | ||
Qt::LayoutDirection | direction = Qt::LeftToRight , |
||
const QString & | space = QStringLiteral(" ") |
||
) |
Insert spaces at regular intervals in a string.
[in] | str | The string to update. |
[in] | groupSize | The number of characters between spaces. If negative or zero, do not insert spaces. |
[in] | direction | The direction from which the characters are counted. |
[in] | space | The space pattern to use. |
QString qtlHtmlLink | ( | const QString & | link, |
const QString & | text = QString() |
||
) |
Build an HTML string containing a link to a URL.
[in] | link | Target URL. |
[in] | text | Text of the link. If empty (the default), link is also used as text. |
QString qtlSizeToString | ( | qlonglong | value, |
int | maxDecimalDigits = 3 , |
||
bool | useBinaryUnits = false , |
||
const QString & | unitName = "B" |
||
) |
Format a size into a human-friendly string.
The resulting string is approximated into the closest "big unit" such as "kB", MB", etc. The default unit is "B" for bytes but it is replaceable.
[in] | value | The size value to format. |
[in] | maxDecimalDigits | Maximum number of decimal digits. Valid values are 0 to 3. |
[in] | useBinaryUnits | If true, use "binary" units, meaning chunks of 1024 units instead of 1000. The abbreviations are updated accordingly. For instance, "1 MB" for "MegaByte" becomes "0.954 MiB" for "MibiByte". The default is false, meaning use standard decimal units or chunks of 1000 units. |
[in] | unitName | Name of the size unit to display. The default is "B" for "byte". |
QVector<wchar_t> qtlToWCharVector | ( | const QString & | str | ) |
Convert a QString into a null-terminated vector of wchar_t.
Can be useful to call native C functions using wide characters.
[in] | str | Qt string to convert. |