一种方式在设计师里面进行设置,另外一种就是直接代码的方式。
QPalette pal;
pal.setColor(QPalette::WindowText,Qt::white);//文本颜色
//pal.setColor(QPalette::Window,Qt::green);//背景颜色
//pal.setColor(QPalette::Background,Qt::green);//同上
//pal.setColor(QPalette::Background,QColor(Qt::green));//同上
pal.setColor(QPalette::Background,QColor(0x80,0xFF,0x00,0x40));//浅绿色透明
ui->label->setPalette(pal);
ui->label->setAutoFillBackground(true);