Re: Translucent Qt widget
I think for playing video with overlay at a proper framerare you have to do some more tricks like having a graphics chip with two framebuffers: Decode video in one framebuffer, have the Qt ui in the other and let the graphics chip do the compositing.
Re: Translucent Qt widget
I finally got it working with help of attributes like WA_PaintOnScreen and setAutofillBackground(true), thereafter I define a transparent color key in my system and fill widget with the same. It works very nice and fast.
Re: Translucent Qt widget
Can you share the final code ?
It might be useful for others out here..
Re: Translucent Qt widget
sure, I have following code for this purpose:
Code:
void Global
::applyAttributes(QWidget *widget
) {
if(widget==NULL)
return;
widget->setAttribute(Qt::WA_NoMousePropagation);
widget->setAutoFillBackground(true);
//widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setAttribute(Qt::WA_PaintOnScreen);
foreach
(QObject *child,widget
->children
()) {
if(child->isWidgetType())
}
}
I call applyAttributes method on parentMost widget in my application and thus every widget is set with WA_PaintOnScreen and autoFillBackground attributes.
Code:
void lobal
::createHole(QWidget *widget
) {
if(widget==NULL)
return;
widget
->setBackgroundRole
(QPalette::Window);
widget->setPalette(transparentPal);
}
I call createHole() on the widget which needs to be transparent to show video. Above mentioned color key (128,64,128) can be any color which is our internal fbset color to make a transparent layer.
Re: Translucent Qt widget
A few questions comments about this
1 - I don't think the recursive applyAttributes is needed. If you set a solid background color for your widget and use that as a chroma key (transparent value) and set setAutoFillBackground(true); for just the one widget you want the hole in you should get the same results. You could even just fillRect of that chroma key into the widget as well.
2 - There are a few problems with this common approach
a - The chroma key you choose, no matter what it is, will be found someplace else on the UI if you have other images/gradients/etc. which will then show up funny once you set the key.
b - There is no way to alpha-composite on top of the widget, i.e. any rendering controls, etc. which are children of the widget are alpha-blended to the widget's background, but then that isn't alpha-blended to the video showing in the background video plane, so it shows up solid.
Question is: How do you solve those problems!
Re: Translucent Qt widget
correct omnilala,
for the same reasons I am not using the approach you mentioned and using the one which I mentioned.
Re: Translucent Qt widget
transparentPal.setColor(QPalette::Window, QColor(128,64,128)); <-- when you have this color code, how can you tell your program to make this color translucent?
Re: Translucent Qt widget
That is a frame buffer set color key.