Qt设置背景颜色,QLabel,QWidget……
作者:互联网
void setBackground(QWidget* widget, const QBrush& brush)
{
QPalette palette(widget->palette());
palette.setBrush(QPalette::Background, brush);
widget->setAutoFillBackground(true);
widget->setPalette(palette);
}
void setBackground(QWidget* widget, const QGradient& gradient)
{
setBackground(widget, QBrush(gradient));
}
void setBackground(QWidget* widget, const QColor& color)
{
setBackground(widget, QBrush(color));
}
void setBackground(QWidget* widget, Qt::GlobalColor color)
{
setBackground(widget, QBrush(color));
}
标签:widget,Qt,color,palette,setBackground,QWidget,QBrush,QLabel 来源: https://www.cnblogs.com/octoberkey/p/16627256.html