您的位置:首页 > 编程语言 > Qt开发

Qt 中关于QWidget的背景颜色和背景图片的设置

2013-12-18 14:25 357 查看
首先设置autoFillBackground属性为真

然后定义一个QPalette对象

设置QPalette对象的背景属性(颜色或图片)

最后设置QWidget对象的Palette

实例:

QWidget *widget = new QWidget;
widget->setAutoFillBackground(true);
QPalette palette;
palette.setColor(QPalette::Background, QColor(192,253,123));
//此处的数值,可以在样式表 中先选中你需要的颜色,然后 cope 数值即可。
//palette.setBrush(QPalette::Background, QBrush(QPixmap(":/background.png")));
widget->setPalette(palette);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: