PDA

View Full Version : Transparent widget and their children widgets



naturalpsychic
15th November 2012, 21:27
Hi I have a transparent dialog box (windowOpacity = 0.5) and I have another dialog box who is (and has to be) child of this dialog.

Is this possible to have full opacity just for that control? I know if I don't make it as child of the previous dialog, it does have full opacity but the reason why i want that to be child is because the parent is in full screen mode and I don't want any bars (for example unity bar in ubuntu) to display when modal dialog is shown as "orphan". I have tried following:

//CODE IN PARENT CONSTRUCTOR
dlgChild = new Dialog(this);
dlgChild->setModal(true);
dlgChild->setWindowFlags(Qt::WindowStaysOnTopHint);
dlgChild->setWindowFlags(Qt::FramelessWindowHint);
for (int i = 0; i < dlgChild->children().size(); i++) {
QObject* child = dlgChild->children().at(i);
static_cast<QWidget*>(child)->setWindowOpacity(1);
}
dlgChild->setWindowOpacity(1);
dlgChild->show();

naturalpsychic
17th November 2012, 06:48
Anyone on this please?

wysota
18th November 2012, 06:47
Opacity is inherited. If you make a widget semi-transparent, its children will be semi-transparent too. I suggest you look for an alternative approach to your problem.

naturalpsychic
18th November 2012, 08:37
Can you suggest any? What would you do if you were me?

wysota
18th November 2012, 09:08
Can you suggest any? What would you do if you were me?

I don't know what your intention is so it is hard to suggest anything.