I am developing an application for Embedded Linux using Qt 4.6.2 where we need to display video along with UI. UI may have a hole along with other UI objects on screen where user can see the video displayed in background.
I apply following attributes to every widget in my application:
widget->setAttribute(Qt::WA_NoMousePropagation);
widget->setAutoFillBackground(true);
//widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setAttribute(Qt::WA_PaintOnScreen);
widget->setAttribute(Qt::WA_NoMousePropagation);
widget->setAutoFillBackground(true);
//widget->setAttribute(Qt::WA_OpaquePaintEvent);
widget->setAttribute(Qt::WA_PaintOnScreen);
To copy to clipboard, switch view to plain text mode
I use the following method to create a hole in UI at required place:
void DVRGlobal
::createHole(QWidget *widget
) {
if(widget==NULL)
return;
//Find out parent most widget
while(parentWidget->parentWidget()!=NULL)
parentWidget = parentWidget->parentWidget();
parentWidget->setAttribute(Qt::WA_TranslucentBackground);
if(parentWidget!=widget)
widget->setStyleSheet("background:transparent");
}
void DVRGlobal::createHole(QWidget *widget)
{
if(widget==NULL)
return;
QWidget *parentWidget = widget;
//Find out parent most widget
while(parentWidget->parentWidget()!=NULL)
parentWidget = parentWidget->parentWidget();
parentWidget->setAttribute(Qt::WA_TranslucentBackground);
if(parentWidget!=widget)
widget->setStyleSheet("background:transparent");
}
To copy to clipboard, switch view to plain text mode
This works with following two problems:
(1) Translucent widget does not repaint itself and I only see the background until I hide/show the complete widget, and it is very slow too.
(2) Any child widget on translucent widget does not repaint itself. i.e. when tool tip disappears on any widget, the background area is not repainted and remains black.
Bookmarks