Semi transparent overlay with opaque child widgets
Hi All,
I want to create opaque child widget over semi transparent parent widget.
If I so setWindowOpacity(.4) parent become transparent and same is propagated to child, I tired with setstylesheet
Code:
background-color: rgba(100,100,100,20%);\
}"));
setStyleSheet(qStrStyleSheet);
but was not able to draw it properly, what I saw was black parent (opaque).
I also tried using
Code:
setAttribute(Qt::WA_TranslucentBackground, true);
setWindowFlags(Qt::FramelessWindowHint)
, this gives exact behavior but parent is transparent, however I want it to be semi-transparent (40%).
I have also tried overwriting paintEvent
Code:
palette.
setColor(backgroundRole
(),
QColor(194,
194,
194,
40));
setPalette(palette);
After searching in google I came across this link , still it's not working for me.
I am using Qt-4.6 with windows-7
Can anyone help me with this.
Re: Semi transparent overlay with opaque child widgets
Could you post a sample image of how you want?
Also be aware that a widget and a window are handled differently in this case.
Re: Semi transparent overlay with opaque child widgets
Thanks for your prompt reply, this issue is resolved.
Code:
setAutoFillBackground(false);
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground);
Code:
{
painter.
setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.
setBrush(QColor(100,
100,
100,
127));
painter.drawRect(0, 0, width(), height());
}
Re: Semi transparent overlay with opaque child widgets
It's been helpful, thanks!