源码实现:
转换方法:
QString CToolBox::qColor2qString(const QColor &color, const QString &type) { if (type == "RGBA") { return QString("rgba(%1,%2,%3,%4)") .arg(color.red()) .arg(color.green()) .arg(color.blue()) .arg(color.alpha()); } else if (type == "RGB") { return QString("rgb(%1,%2,%3)") .arg(color.red()) .arg(color.green()) .arg(color.blue()); } else if (type == "HEX") { return QString().sprintf("#%1%02X%02X%02X", color.red(), color.green(), color.blue()) .arg(color.alpha() != 255 ? QString().sprintf("%02X", color.alpha()) : QString()); } return color.name(); }