PDA

View Full Version : Question about semi-transparent child widget



lpfxyww
5th November 2013, 04:58
Hi,
I want to draw a semi-transparent child QPushButton on top of a parent Widget which inherits from QGLWidget and repaints itsself every 20ms. The parent widget is implemented in the opensource Project OpenSceneGraph. The following codes are used:
***
ui.setupUi(this);

ui.pushButton->setAutoFillBackground(true);
ui.pushButton->setFlat(true);
ui.pushButton->setStyleSheet("background-color:transparent");
***
then the result is a fully black button on front of the parent widget but not a semi-transparent button(as shown in attachment fig.1). When it comes with the condition of two overlapped QPushButton, the code works well that the upper button is a semi-transparent(fig.2). The follwing two attachments show the result of my code.
Is there anything wrong with my code settings?(winwods 7 x64, vs 2010,qt 4.8.5)
97549755

wagmare
5th November 2013, 06:08
try using
pushButton->setWindowOpacity(0.x);
or
QPalette palette ;
palette.setBrush(QPalette::Background, Qt::transparent);
button->setPalette(palette);

with
button->setAutoFillBackground(false);

lpfxyww
5th November 2013, 10:33
try using
pushButton->setWindowOpacity(0.x);
or
QPalette palette ;
palette.setBrush(QPalette::Background, Qt::transparent);
button->setPalette(palette);

with
button->setAutoFillBackground(false);

Thank you. I tried and it still not work. Also I tried in the src code of OsgEarth samples. Maybe sth else cause this.