23 #include <QRegularExpression> 25 static QRegularExpression
regex_qcolor (
"^(?:(?:#[[:xdigit:]]{3})|(?:#[[:xdigit:]]{6})|(?:[[:alpha:]]+))$");
26 static QRegularExpression
regex_func_rgb (R
"(^rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)"); 28 static QRegularExpression
regex_func_rgba (R
"(^rgba?\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)"); 35 if ( !alpha || color.alpha() == 255 )
37 return color.name()+QString(
"%1").arg(color.alpha(), 2, 16, QChar(
'0'));
42 QString xs =
string.trimmed();
43 QRegularExpressionMatch match;
46 if ( match.hasMatch() )
52 if ( match.hasMatch() )
55 match.captured(1).toInt(),
56 match.captured(2).toInt(),
57 match.captured(3).toInt()
64 if ( match.hasMatch() )
67 xs.mid(1,2).toInt(
nullptr,16),
68 xs.mid(3,2).toInt(
nullptr,16),
69 xs.mid(5,2).toInt(
nullptr,16),
70 xs.mid(7,2).toInt(
nullptr,16)
75 if ( match.hasMatch() )
78 match.captured(1).toInt(),
79 match.captured(2).toInt(),
80 match.captured(3).toInt(),
81 match.captured(4).toInt()
static QRegularExpression regex_func_rgba(R"(^rgba?\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")
static QRegularExpression regex_hex_rgba("^#[[:xdigit:]]{8}$")
static QRegularExpression regex_func_rgb(R"(^rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)$)")
static QRegularExpression regex_qcolor("^(?:(?:#[[:xdigit:]]{3})|(?:#[[:xdigit:]]{6})|(?:[[:alpha:]]+))$")