<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to play a video on a translucent QWidget?]]></title><description><![CDATA[<p dir="auto">#include "videoplayer.h"<br />
#include &lt;QtWidgets/QApplication&gt;<br />
#include "qboxlayout.h"<br />
#include "qvideowidget.h"<br />
int main(int argc, char *argv[])<br />
{<br />
QApplication app(argc, argv);<br />
QWidget *w = new QWidget;</p>
<pre><code>w-&gt;setWindowFlags(Qt :: Window | Qt::FramelessWindowHint );
w-&gt;setAttribute(Qt::WA_TranslucentBackground, true);
w-&gt;setMinimumSize(300,200);

QVideoWidget *videoWidget = new QVideoWidget;
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout-&gt;setMargin(0);
controlLayout-&gt;addWidget(videoWidget);
w-&gt;setLayout(controlLayout);

QMediaPlayer mediaPlayer;
mediaPlayer.setVideoOutput(videoWidget);
mediaPlayer.setMedia(QUrl::fromLocalFile("C:/1.wmv"));
videoWidget-&gt;show();
mediaPlayer.play();

w-&gt;show();
return app.exec();
</code></pre>
<p dir="auto">}</p>
<p dir="auto">when two line w-&gt;setWindowFlags(Qt :: Window | Qt::FramelessWindowHint ); w-&gt;setAttribute(Qt::WA_TranslucentBackground, true); remove the movie show correctly.<br />
somebody tell ,in this case i use a custom video widget and in paintEvent after createing QPainter painter(this); add<br />
painter.setCompositionMode(QPainter::RasterOp_SourceAndNotDestination);  but i use, it is No effect! Someone met?Someone met ?Someone solution?</p>
]]></description><link>https://forum.qt.io/topic/60992/how-to-play-a-video-on-a-translucent-qwidget</link><generator>RSS for Node</generator><lastBuildDate>Fri, 19 Jun 2026 18:41:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/60992.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 25 Nov 2015 02:17:44 GMT</pubDate><ttl>60</ttl></channel></rss>