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));
}
posted on 2022-08-26 13:19 OctoberKey 阅读(342) 评论(0) 收藏 举报