添加窗哗帆亏体背景
this-setStyleSheet(tr("background:url(pic.jpg)"))方法二:
this-setAutoFillBackground(true)
QPalette
myPalette
myPalette.setBrush(this-backgroundRole(),
QBrush(QPixmap("./pic.jpg")))
this-setPalette(myPalette)
二,改变背景颜色在窗体构造函乱神数中加入:
方法一
/早敏/setStyleSheet("background-color:rgb(19,45,106)")
// setAttribute(Qt::WA_StyledBackground)没有这句,上一句不起作用,但子窗口背景色也变了
this->setStyleSheet("QWidget:!hover{background-color:rgb(255,0,0)}")//用过滤,但这句裂睁侍写的不对
方法二
fQPalette pal(this->palette())
//设置背景肆吵黑色
pal.setColor(QPalette::Background, QColor(19,45,106))
setAutoFillBackground(true)
setPalette(pal)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)