封装
void XXXSystem::initQssStyle(QColor color)
{
QString cssStr;
if (color == Qt::white)
cssStr = ":/qss/flatwhite.css";
else if (color == Qt::black)
cssStr = ":/qss/psblack.css";
else
cssStr = ":/qss/lightblue.css";
QString qss;
QFile file(cssStr);
if (file.open(QFile::ReadOnly))
{
qss = QLatin1String(file.readAll());
QString paletteColor = qss.mid(20, 7);
qApp->setPalette(QPalette(QColor(paletteColor)));
qApp->setStyleSheet(qss);
file.close();
}
}
调用
this->initQssStyle(Qt::blue);
this->initQssStyle(Qt::white);
this->initQssStyle(Qt::black);