Transparent QWebView over Phonon VideoWidget
Hello everyone.
I need put QWebView (ok, any QWidget) with transparent background over Phonon VideoWidget,
I doing it so:
- m_video = new Phonon::VideoWidget;
- .....
- view->setHtml("<div style=\"color:#FFFFFF;font-size:36px;\">Hello Qt!</div>");
- view->setPalette(palette);
- m_video->show();
- m_video->resize(640, 480);
- view->setFixedSize(m_video->width(), m_video->height());
But I’m not see video under white text, I just see white text on black rectangle.
Of course, without overlay widget I see video normally.
Any suggestions?
7 replies
I found workaround for this issue:
This is subclass of Phonon::VideoWidget with overrided events methods.
- class OverlayedVideoWidget : public Phonon::VideoWidget
- {
- public:
- Phonon::VideoWidget(parent),
- m_overlayWidget(0)
- {
- }
- {
- m_overlayWidget = widget;
- }
- protected:
- {
- if (m_overlayWidget)
- m_overlayWidget->move(event->pos());
- }
- {
- if (m_overlayWidget)
- m_overlayWidget->resize(event->size());
- }
- {
- if (m_overlayWidget)
- m_overlayWidget->hide();
- }
- {
- if (m_overlayWidget)
- m_overlayWidget->show();
- }
- {
- if (m_overlayWidget)
- m_overlayWidget->close();
- }
- private:
- };
Usage example:
- m_video = new OverlayedVideoWidget;
- view->setHtml("<div style=\"color:#FFFFFF;font-size:36px;\">Hello Qt!</div>");
- view->setPalette(palette);
- view->page()->setPalette(palette);
- m_video->setOverlayWidget(view);
- m_video->show();
- m_video->resize(640, 480);
Main idea of this workaround is set to overlayed widget ToolTip window flag and connect move, resize, etc events of both objects.
Hello once again,
the solution works, but do you think there would be probably a better and cleaner solution ? (referring to http://stackoverflow.com/questions/4473709/play-a-video-with-custom-overlay-graphics/13120078#13120078)
the solution works, but do you think there would be probably a better and cleaner solution ? (referring to http://stackoverflow.com/questions/4473709/play-a-video-with-custom-overlay-graphics/13120078#13120078)
I am not sure if this solution is better or cleaner but it worked for me. Here is a complete code example, which finally worked after one day of trying…
http://www.qtcentre.org/archive/index.php/t-39496.html
Good Luck!
You must log in to post a reply. Not a member yet? Register here!


