PDA

View Full Version : QWidget inside QGroupbox semi transparent [Qt 4.3.1]



desch
18th November 2008, 14:47
Hi everybody,

I know opacity and semi transparency was a subject mainly discussed, but I haven't found what I'm looking for:D

I try to set transparency to 0.5 with Qpainter::setOpacity(0.5) to widgets inside a QGroupbox; list of widgets could be any kind of Qt classical Widgets(QSlider, QComboBox, QPushButton, ...)

I didn't succeed to set QGroupbox transparency to all child widgets.:mad:

I'm afraid, I have to customize all PainEvent of All widgets inserted in QGroupBox, isn't it?

Tell me if I should give up since I have no idea about the widget type inserted through QGroupbox (for the moment).

Thanks for your help,

David

wysota
18th November 2008, 17:40
Can we see a screenshot?

aamer4yu
19th November 2008, 04:20
Will QWidget::setWindowOpacity() work in ur case ??
you can try it on group box...

desch
19th November 2008, 08:16
the setWindowOpacity is used for top-level Widget; the aim is to get a standalone widget able to take an opacity different at 0.5 and able to transmit this transparency to all any child widget inside....I attached the picture

this was obtained with this code to the subclass of QGroupBox


void CMyGroupBox::paintEvent(QPaintEvent *)
{
QStylePainter paint(this);
QStyleOptionGroupBox option;
initStyleOption(&option);
paint.setOpacity(0.25);
paint.drawComplexControl(QStyle::CC_GroupBox, option);
}

wysota
19th November 2008, 09:48
And you want everything to be semi-transparent? Or just the children of the window? Or a specific child?

desch
19th November 2008, 09:57
the best is to set all children of Qgroupbox Semi transparent;

but more I search , more I understand I have to subclass all children I would like to insert into the QGroupbox

wysota
19th November 2008, 10:25
It might be easier to use QWidget::render() to get a pixmap of the item and its children and then render the result with opacity of your choice on the destination window.

drsm
26th February 2009, 10:00
It might be easier to use QWidget::render() to get a pixmap of the item and its children and then render the result with opacity of your choice on the destination window.

do you have any ideas how to do this?
the rendering is not a problem,
but how to render results??