问题解决了。。。。
在子widget的构造函数里添加如下几句:
QPalette myPalette;
QColor myColor(0,0,0);
myColor.setAlphaF(0.2);
myPalette.setBrush(backgroundRole(),myColor);
this->setPalette(myPalette);
this->setAutoFillBackground(true);
原理是:改子widget的背景色+修改alpha值(设置半透明)
改子widget的背景色 :
QPalette myPalette;
QColor myColor(0,0,0);
myPalette.setBrush(backgroundRole(),myColor);
this->setPalette(myPalette);
this->setAutoFillBackground(true);//这句很关键,缺少的话,背景色修改不成功
修改alpha值:
myColor.setAlphaF(0.2);//通过设置alpha值来改变透明度
泥马,设置半透明就只需这么简单的一条语句,叫爹爹不理,叫娘娘不爱的,有意思么
感谢看帖的各位兄弟姐妹,谢谢你们捧了个人场