JKQTPlotter trunk/v5.0.0
an extensive Qt5+Qt6 Plotter framework (including a feature-richt plotter widget, a speed-optimized, but limited variant and a LaTeX equation renderer!), written fully in C/C++ and without external dependencies
Loading...
Searching...
No Matches
String(-Conversion) Functions
Collaboration diagram for String(-Conversion) Functions:

Functions

JKQTCOMMON_LIB_EXPORT QString jkqtp_backslashEscape (const QString &txt)
 replace all linebreaks by "\\n" , "\\r" ...
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_booltostr (bool data)
 convert a boolean to a string
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_bytestostr (double bytes)
 convert a number of bytes to a string, formatting e.g. 1024 as 1kB, ...
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_chartostr (char data)
 convert a character to a string
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize (const QString &data)
 filename-ize a string, i.e. replace every non-number and non-character (and also not _ -) character to _
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattohtmlqstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=1e-16, double minNoExponent=1e-3, double maxNoExponent=1e4)
 convert a double to a string, encoding powers of ten as exponent with HTML tags
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattohtmlstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=1e-16, double minNoExponent=1e-3, double maxNoExponent=1e4)
 convert a double to a string, encoding powers of ten as exponent with HTML tags
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattolatexqstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=1e-16, double minNoExponent=1e-3, double maxNoExponent=1e4, bool ensurePlusMinus=false)
 convert a double to a string, encoding powers of ten as exponent in LaTeX notation (e.g. -1.23\cdot 10^{-5})
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattolatexstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=1e-16, double minNoExponent=1e-3, double maxNoExponent=1e4, bool ensurePlusMinus=false, const std::string &multOperator="\\times")
 convert a double to a string, encoding powers of ten as exponent in LaTeX notation (e.g. -1.23\cdot 10^{-5})
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattolatexunitqstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=std::numeric_limits< double >::min() *4)
 convert a double to a LaTeX-encoded string, encoding powers of ten as characters, e.g. jkqtp_floattounitqstr(1000) will result in "1k"
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattolatexunitstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=std::numeric_limits< double >::min() *4)
 convert a double to a LaTeX-encoded string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattoqstr (const QLocale &loc, double data, char format='f', int past_comma=-1, bool remove_trail0=false)
 convert a float to a string using format (f|e|E|g|G ) with given number of decimals after comma past_comma and optional removal of trailing zeros behind decimal separator remove_trail0. Uses given QLocal loc .
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattoqstr (double data, char format='f', int past_comma=-1, bool remove_trail0=false)
 convert a float to a string using format (f|e|E|g|G ) with given number of decimals after comma past_comma and optional removal of trailing zeros behind decimal separator remove_trail0. Uses system local, disables not use Group-Separator
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattostr (double data, int past_comma=-1, bool remove_trail0=false, double belowIsZero=1e-16)
 convert a double to a string
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_floattounitqstr (double data, int past_comma=5, bool remove_trail0=false)
 convert a double to a string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattounitstr (double data, int past_comma=5, bool remove_trail0=false, double belowIsZero=std::numeric_limits< double >::min() *4)
 convert a double to a string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"
 
template<class T1 >
std::string jkqtp_format (const std::string &templ, T1 d1)
 std::string wrapper around sprintf()
 
template<class T1 , class T2 >
std::string jkqtp_format (const std::string &templ, T1 d1, T2 d2)
 std::string wrapper around sprintf()
 
template<class T1 , class T2 , class T3 >
std::string jkqtp_format (const std::string &templ, T1 d1, T2 d2, T3 d3)
 std::string wrapper around sprintf()
 
template<class T1 , class T2 , class T3 , class T4 >
std::string jkqtp_format (const std::string &templ, T1 d1, T2 d2, T3 d3, T4 d4)
 std::string wrapper around sprintf()
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_inttohex (long data)
 convert an integer to a hex string
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_inttostr (long data)
 convert an integer to a string
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_KeyboardModifiers2String (Qt::KeyboardModifiers modifiers, bool useNONE=true)
 convert a Qt::KeyboardModifiers to a QString
 
JKQTCOMMON_LIB_EXPORT const QStringList & jkqtp_listNamedColors ()
 list the (machine-readable) names of all predefined colors
 
JKQTCOMMON_LIB_EXPORT QColor jkqtp_lookupQColorName (const QString &color, bool namesOnly=false, bool *nameFound=nullptr)
 converts a QString into a QColor, does not support the ,alpha%-notation, use jkqtp_String2QColor() for a full conversion!
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String (Qt::MouseButton button, bool useNONE=true)
 convert a Qt::MouseButton to a QString
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_QBrushStyle2String (Qt::BrushStyle style)
 converts a Qt::BrushStyle into a string
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_QColor2String (QColor color, bool useSpecialTransparencySyntax=true)
 converts a QColor into a string using the jkqtp_rgbtostring() method.
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_QPenStyle2String (Qt::PenStyle style)
 converts a QT::PenStyle into a string
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_rgbtostring (unsigned char r, unsigned char g, unsigned char b, unsigned char a=255, bool useSpecialTransparencySyntax=true)
 converts a RGBA color into a string
 
JKQTCOMMON_LIB_EXPORT bool jkqtp_rxContains (const QString &text, const QString &regex, size_t offset=0, QStringList *caps=nullptr)
 returns true, if text contains a match to the given regular expression regex, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]
 
JKQTCOMMON_LIB_EXPORT bool jkqtp_rxExactlyMatches (const QString &text, const QString &regex, QStringList *caps=nullptr)
 returns true, if text exactly matches the given regular expression regex, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]
 
JKQTCOMMON_LIB_EXPORT size_t jkqtp_rxIndexIn (const QString &text, const QString &regex, size_t offset=0, QStringList *caps=nullptr)
 returns the next match (i.e. its index) of the given regular expression regex within text, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]
 
JKQTCOMMON_LIB_EXPORT bool jkqtp_rxPartiallyMatchesAt (const QString &text, const QString &regex, size_t offset=0, QStringList *caps=nullptr)
 returns true, if text partially matches the given regular expression regex, starting from offset (and the match starts at offset !!!) and optionally returns the match in caps =[fullmatch, cap1,cap2,...]
 
JKQTCOMMON_LIB_EXPORT Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers (const QString &modifiers)
 convert a QString (created by jkqtp_KeyboardModifiers2String() ) to Qt::KeyboardModifiers
 
JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton (const QString &button)
 convert a QString (created by jkqtp_MouseButton2String() ) to Qt::MouseButton
 
JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyle (const QString &style)
 converts a QString into a Qt::BrushStyle
 
JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyleExt (const QString &style, QGradient *gradient=nullptr, QPixmap *image=nullptr)
 converts a QString into a Qt::BrushStyle. commpared to jkqtp_String2QBrushStyle(), this method can parse more complex pattern/brush descriptions, such as for colors, gradients or images, which are output in color, gradient and image
 
JKQTCOMMON_LIB_EXPORT QColor jkqtp_String2QColor (QString color)
 converts a QString into a QColor, compatible with jkqtp_QColor2String(QColor color);
 
JKQTCOMMON_LIB_EXPORT Qt::PenStyle jkqtp_String2QPenStyle (const QString &style)
 converts a QString into a Qt::PenStyle
 
JKQTCOMMON_LIB_EXPORT bool jkqtp_strtobool (const std::string &data)
 convert a string to a boolean
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_to_valid_variable_name (const std::string &input)
 clean a string to be usable as a variable name, e.g. in an expression parser, or a C++-expression
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_tolower (const std::string &s)
 convert a string to lower-case characters
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_toupper (const std::string &s)
 convert a string to upper-case
 
JKQTCOMMON_LIB_EXPORT QString jkqtp_toValidVariableName (const QString &input)
 create a valid variable name from the string, i.e. a string with only characters and digits and '_'. ALso the first character has to be a charcter.
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_uinttostr (unsigned long data)
 convert an unsigned int to a string
 
JKQTCOMMON_LIB_EXPORT std::string jkqtp_UnicodeToUTF8 (uint32_t codepoint)
 converts a Unicode codepoint into a UTF8-sequence
 
QString JKQTPCDoubleToQString (double value)
 convert a double to a string, using the loacle "C"
 
QString JKQTPDoubleToQString (double value, int prec=10, char f='g', QChar decimalSeparator='.')
 convert a double to a string
 
QString & JKQTPExtendString (QString &s, const QString &separator, const QString &extension)
 convert a double to a string
 
JKQTCOMMON_LIB_EXPORT QString jkVariantListToString (const QList< QVariant > &data, const QString &separator=QString(", "))
 convert a QList<QVariant> to a string
 

Detailed Description

Offers diverse function to convert different datatypes (e.g. double, int, diverse enums) to and from strings and for string manipulation.

Function Documentation

◆ jkqtp_backslashEscape()

JKQTCOMMON_LIB_EXPORT QString jkqtp_backslashEscape ( const QString &  txt)

replace all linebreaks by "\\n" , "\\r" ...

◆ jkqtp_booltostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_booltostr ( bool  data)

convert a boolean to a string

◆ jkqtp_bytestostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_bytestostr ( double  bytes)

convert a number of bytes to a string, formatting e.g. 1024 as 1kB, ...

◆ jkqtp_chartostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_chartostr ( char  data)

convert a character to a string

◆ jkqtp_filenameize()

JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize ( const QString &  data)

filename-ize a string, i.e. replace every non-number and non-character (and also not _ -) character to _

◆ jkqtp_floattohtmlqstr()

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattohtmlqstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = 1e-16,
double  minNoExponent = 1e-3,
double  maxNoExponent = 1e4 
)

convert a double to a string, encoding powers of ten as exponent with HTML tags

◆ jkqtp_floattohtmlstr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattohtmlstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = 1e-16,
double  minNoExponent = 1e-3,
double  maxNoExponent = 1e4 
)

convert a double to a string, encoding powers of ten as exponent with HTML tags

◆ jkqtp_floattolatexqstr()

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattolatexqstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = 1e-16,
double  minNoExponent = 1e-3,
double  maxNoExponent = 1e4,
bool  ensurePlusMinus = false 
)

convert a double to a string, encoding powers of ten as exponent in LaTeX notation (e.g. -1.23\cdot 10^{-5})

◆ jkqtp_floattolatexstr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattolatexstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = 1e-16,
double  minNoExponent = 1e-3,
double  maxNoExponent = 1e4,
bool  ensurePlusMinus = false,
const std::string &  multOperator = "\\times" 
)

convert a double to a string, encoding powers of ten as exponent in LaTeX notation (e.g. -1.23\cdot 10^{-5})

◆ jkqtp_floattolatexunitqstr()

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattolatexunitqstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = std::numeric_limits< double >::min() *4 
)

convert a double to a LaTeX-encoded string, encoding powers of ten as characters, e.g. jkqtp_floattounitqstr(1000) will result in "1k"

◆ jkqtp_floattolatexunitstr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattolatexunitstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = std::numeric_limits< double >::min() *4 
)

convert a double to a LaTeX-encoded string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"

◆ jkqtp_floattoqstr() [1/2]

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattoqstr ( const QLocale &  loc,
double  data,
char  format = 'f',
int  past_comma = -1,
bool  remove_trail0 = false 
)

convert a float to a string using format (f|e|E|g|G ) with given number of decimals after comma past_comma and optional removal of trailing zeros behind decimal separator remove_trail0. Uses given QLocal loc .

◆ jkqtp_floattoqstr() [2/2]

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattoqstr ( double  data,
char  format = 'f',
int  past_comma = -1,
bool  remove_trail0 = false 
)

convert a float to a string using format (f|e|E|g|G ) with given number of decimals after comma past_comma and optional removal of trailing zeros behind decimal separator remove_trail0. Uses system local, disables not use Group-Separator

◆ jkqtp_floattostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattostr ( double  data,
int  past_comma = -1,
bool  remove_trail0 = false,
double  belowIsZero = 1e-16 
)

convert a double to a string

◆ jkqtp_floattounitqstr()

JKQTCOMMON_LIB_EXPORT QString jkqtp_floattounitqstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false 
)

convert a double to a string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"

◆ jkqtp_floattounitstr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_floattounitstr ( double  data,
int  past_comma = 5,
bool  remove_trail0 = false,
double  belowIsZero = std::numeric_limits< double >::min() *4 
)

convert a double to a string, encoding powers of ten as characters, e.g. jkqtp_floattounitstr(1000) will result in "1k"

◆ jkqtp_format() [1/4]

template<class T1 >
std::string jkqtp_format ( const std::string &  templ,
T1  d1 
)
inline

std::string wrapper around sprintf()

◆ jkqtp_format() [2/4]

template<class T1 , class T2 >
std::string jkqtp_format ( const std::string &  templ,
T1  d1,
T2  d2 
)
inline

std::string wrapper around sprintf()

◆ jkqtp_format() [3/4]

template<class T1 , class T2 , class T3 >
std::string jkqtp_format ( const std::string &  templ,
T1  d1,
T2  d2,
T3  d3 
)
inline

std::string wrapper around sprintf()

◆ jkqtp_format() [4/4]

template<class T1 , class T2 , class T3 , class T4 >
std::string jkqtp_format ( const std::string &  templ,
T1  d1,
T2  d2,
T3  d3,
T4  d4 
)
inline

std::string wrapper around sprintf()

◆ jkqtp_inttohex()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_inttohex ( long  data)

convert an integer to a hex string

◆ jkqtp_inttostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_inttostr ( long  data)

convert an integer to a string

◆ jkqtp_KeyboardModifiers2String()

JKQTCOMMON_LIB_EXPORT QString jkqtp_KeyboardModifiers2String ( Qt::KeyboardModifiers  modifiers,
bool  useNONE = true 
)

convert a Qt::KeyboardModifiers to a QString

Parameters
modifiersthe object to convert
useNONEif true the function will return "NONE" if modifiers==Qt::NoMofifiers. Otherwise the function will return an empty string ( jkqtp_String2KeyboardModifiers() can cope with both variants)
See also
jkqtp_String2KeyboardModifiers()

◆ jkqtp_listNamedColors()

JKQTCOMMON_LIB_EXPORT const QStringList & jkqtp_listNamedColors ( )

list the (machine-readable) names of all predefined colors

◆ jkqtp_lookupQColorName()

JKQTCOMMON_LIB_EXPORT QColor jkqtp_lookupQColorName ( const QString &  color,
bool  namesOnly = false,
bool *  nameFound = nullptr 
)

converts a QString into a QColor, does not support the ,alpha%-notation, use jkqtp_String2QColor() for a full conversion!

This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise.

Parameters
colorthe color name to convert
namesOnlyif true , the function only compares against the list of CSS colors; otherwise it passes the string also on to QColor()-constructor, which interprets e.g. #AABBCC
[out]nameFoundoptional return value that signifies whether a name was found

◆ jkqtp_MouseButton2String()

JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String ( Qt::MouseButton  button,
bool  useNONE = true 
)

convert a Qt::MouseButton to a QString

Parameters
buttonthe object to convert
useNONEif true the function will return "NONE" if button==Qt::NoButton. Otherwise the function will return an empty string ( jkqtp_String2MouseButton() can cope with both variants)
See also
jkqtp_MouseButton2String()

◆ jkqtp_QBrushStyle2String()

JKQTCOMMON_LIB_EXPORT QString jkqtp_QBrushStyle2String ( Qt::BrushStyle  style)

converts a Qt::BrushStyle into a string

◆ jkqtp_QColor2String()

JKQTCOMMON_LIB_EXPORT QString jkqtp_QColor2String ( QColor  color,
bool  useSpecialTransparencySyntax = true 
)

converts a QColor into a string using the jkqtp_rgbtostring() method.

This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise.

◆ jkqtp_QPenStyle2String()

JKQTCOMMON_LIB_EXPORT QString jkqtp_QPenStyle2String ( Qt::PenStyle  style)

converts a QT::PenStyle into a string

◆ jkqtp_rgbtostring()

JKQTCOMMON_LIB_EXPORT QString jkqtp_rgbtostring ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = 255,
bool  useSpecialTransparencySyntax = true 
)

converts a RGBA color into a string

This returns a QString which contains the name of named colors and the RGBA values in a QT readable form othertwise.

Parameters
rred value of the color to convert
ggreen value of the color to convert
bblue value of the color to convert
aalpha value of the color to convert
useSpecialTransparencySyntaxis set (true ), the function uses a special syntax to denote color and transparency: color,trans

◆ jkqtp_rxContains()

JKQTCOMMON_LIB_EXPORT bool jkqtp_rxContains ( const QString &  text,
const QString &  regex,
size_t  offset = 0,
QStringList *  caps = nullptr 
)

returns true, if text contains a match to the given regular expression regex, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]

Note
this function uses an internal cache, so the regex does not have to be compiled every time this is called (with the same regex ).
See also
jkqtp_rxExactlyMatches(), jkqtp_rxIndexIn(), jkqtp_rxContains(), jkqtp_rxPartiallyMatchesAt()

◆ jkqtp_rxExactlyMatches()

JKQTCOMMON_LIB_EXPORT bool jkqtp_rxExactlyMatches ( const QString &  text,
const QString &  regex,
QStringList *  caps = nullptr 
)

returns true, if text exactly matches the given regular expression regex, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]

Note
this function uses an internal cache, so the regex does not have to be compiled every time this is called (with the same regex ).
See also
jkqtp_rxExactlyMatches(), jkqtp_rxIndexIn(), jkqtp_rxContains(), jkqtp_rxPartiallyMatchesAt()

◆ jkqtp_rxIndexIn()

JKQTCOMMON_LIB_EXPORT size_t jkqtp_rxIndexIn ( const QString &  text,
const QString &  regex,
size_t  offset = 0,
QStringList *  caps = nullptr 
)

returns the next match (i.e. its index) of the given regular expression regex within text, starts from offset and optionally returns the match in caps =[fullmatch, cap1,cap2,...]

Note
this function uses an internal cache, so the regex does not have to be compiled every time this is called (with the same regex ).
See also
jkqtp_rxExactlyMatches(), jkqtp_rxIndexIn(), jkqtp_rxContains(), jkqtp_rxPartiallyMatchesAt()

◆ jkqtp_rxPartiallyMatchesAt()

JKQTCOMMON_LIB_EXPORT bool jkqtp_rxPartiallyMatchesAt ( const QString &  text,
const QString &  regex,
size_t  offset = 0,
QStringList *  caps = nullptr 
)

returns true, if text partially matches the given regular expression regex, starting from offset (and the match starts at offset !!!) and optionally returns the match in caps =[fullmatch, cap1,cap2,...]

Note
this function uses an internal cache, so the regex does not have to be compiled every time this is called (with the same regex ).
See also
jkqtp_rxExactlyMatches(), jkqtp_rxIndexIn(), jkqtp_rxContains(), jkqtp_rxPartiallyMatchesAt()

◆ jkqtp_String2KeyboardModifiers()

JKQTCOMMON_LIB_EXPORT Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers ( const QString &  modifiers)

◆ jkqtp_String2MouseButton()

JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton ( const QString &  button)

◆ jkqtp_String2QBrushStyle()

JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyle ( const QString &  style)

converts a QString into a Qt::BrushStyle

See also
jkqtp_String2QBrushStyleExt() for a more complex parser

◆ jkqtp_String2QBrushStyleExt()

JKQTCOMMON_LIB_EXPORT Qt::BrushStyle jkqtp_String2QBrushStyleExt ( const QString &  style,
QGradient *  gradient = nullptr,
QPixmap *  image = nullptr 
)

converts a QString into a Qt::BrushStyle. commpared to jkqtp_String2QBrushStyle(), this method can parse more complex pattern/brush descriptions, such as for colors, gradients or images, which are output in color, gradient and image

Parameters
stylethe string to be parsed
[out]gradientoutput parameter for a parsed gradient
[out]imageoutput parameter for a parsed image
See also
jkqtp_String2QBrushStyle()

◆ jkqtp_String2QColor()

JKQTCOMMON_LIB_EXPORT QColor jkqtp_String2QColor ( QString  color)

converts a QString into a QColor, compatible with jkqtp_QColor2String(QColor color);

This function converts a color name to a QColor. It extends the names by the following optional synatxes (basically the CSS-syntax with even more options):

  • This function allows to add the alpha-value as "<color_name>,<alpha>" as integer betwee 0 and 255 or as "<color_name>,<transparency_percent>%" in the range of 0..100 % (i.e. (1-transparency_percent/100)*255).
  • Also "<color_name>,a<alpha_percent>%" in the range of 0..100 % (i.e. alpha_percent/100*255).
  • "gray<percent>" in the range of 0..100 generates a gray value with 0%=black and 100%=white. Also works for "blue"|"green"|"red"|...
  • You can use full CSS-color syntax with functions "rgb(R,G,B)" , "rgba(...)" , "hsl(...)" , "hsv(...)" , "gray(...)" , "green(...)" , "red(...)" , "blue(...)". The function also support %-values as parameters and whitespace, comma or slash as value separatos!
  • Finally the default Qt color definitions are supported, i.e. #RGB , #RRGGBB , #AARRGGBB , #RRRGGGBBB , #RRRRGGGGBBBB

◆ jkqtp_String2QPenStyle()

JKQTCOMMON_LIB_EXPORT Qt::PenStyle jkqtp_String2QPenStyle ( const QString &  style)

converts a QString into a Qt::PenStyle

◆ jkqtp_strtobool()

JKQTCOMMON_LIB_EXPORT bool jkqtp_strtobool ( const std::string &  data)

convert a string to a boolean

◆ jkqtp_to_valid_variable_name()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_to_valid_variable_name ( const std::string &  input)

clean a string to be usable as a variable name, e.g. in an expression parser, or a C++-expression

◆ jkqtp_tolower()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_tolower ( const std::string &  s)

convert a string to lower-case characters

◆ jkqtp_toupper()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_toupper ( const std::string &  s)

convert a string to upper-case

◆ jkqtp_toValidVariableName()

JKQTCOMMON_LIB_EXPORT QString jkqtp_toValidVariableName ( const QString &  input)

create a valid variable name from the string, i.e. a string with only characters and digits and '_'. ALso the first character has to be a charcter.

◆ jkqtp_uinttostr()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_uinttostr ( unsigned long  data)

convert an unsigned int to a string

◆ jkqtp_UnicodeToUTF8()

JKQTCOMMON_LIB_EXPORT std::string jkqtp_UnicodeToUTF8 ( uint32_t  codepoint)

converts a Unicode codepoint into a UTF8-sequence

See also
https://stackoverflow.com/questions/19968705/unsigned-integer-as-utf-8-value

◆ JKQTPCDoubleToQString()

QString JKQTPCDoubleToQString ( double  value)
inline

convert a double to a string, using the loacle "C"

◆ JKQTPDoubleToQString()

QString JKQTPDoubleToQString ( double  value,
int  prec = 10,
char  f = 'g',
QChar  decimalSeparator = '.' 
)
inline

convert a double to a string

◆ JKQTPExtendString()

QString & JKQTPExtendString ( QString &  s,
const QString &  separator,
const QString &  extension 
)
inline

convert a double to a string

◆ jkVariantListToString()

JKQTCOMMON_LIB_EXPORT QString jkVariantListToString ( const QList< QVariant > &  data,
const QString &  separator = QString(", ") 
)

convert a QList<QVariant> to a string