I am working with a QWidget elements which contains child elements, what I need is some way to make this widget semi transparent, completely, including its childs.
I have seen a method for QWidgets which is QWidget::setWindowOpacity() but this works only if the widget is a window itself, and in my case this widget is part of a layout.
The goal of all this, is me being able to make this widget fade when appearing or disappearing.
Thanks for any ideas, hopefully not making a custom widget, but if there is no more alternatives, I can do it anyway.
You can use QGraphicsOpacityEffect.
A sample code fragment for 50% transparency would be:
ui->setupUi(this);
QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect(ui->pushButton);
effect->setOpacity(0.5);
ui->pushButton->setGraphicsEffect(effect);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With