<?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[Can&#x27;t paint over QVideoWidget in Qt6]]></title><description><![CDATA[<p dir="auto">It used to work in Qt5 with QCameraViewfinder but I can't make it work in Qt6. Here is an example:</p>
<pre><code>#include &lt;QApplication&gt;
#include &lt;QCamera&gt;
#include &lt;QMediaDevices&gt;
#include &lt;QMediaCaptureSession&gt;
#include &lt;QVideoWidget&gt;
#include &lt;QPainter&gt;

class myVideoWidget : public QVideoWidget
{
public:
    explicit myVideoWidget(QWidget* parent = nullptr) : QVideoWidget(parent) {
    }

protected:
    void paintEvent(QPaintEvent* event)  override {
        QVideoWidget::paintEvent(event);

        QPainter painter(this);
        QPen pen;
        pen.setWidth(20);
        pen.setColor(Qt::black);
        painter.setPen(pen);
        painter.drawRect(10, 10, 500, 500);
    }

};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    myVideoWidget videoWidget;
    videoWidget.resize(640, 480);
    videoWidget.show();

    QCamera camera(QMediaDevices::defaultVideoInput());
    camera.start();

    QMediaCaptureSession mediaCaptureSession;
    mediaCaptureSession.setCamera(&amp;camera);
    mediaCaptureSession.setVideoOutput(&amp;videoWidget);

    return a.exec();
}
</code></pre>
]]></description><link>https://forum.qt.io/topic/149462/can-t-paint-over-qvideowidget-in-qt6</link><generator>RSS for Node</generator><lastBuildDate>Sun, 01 Nov 2026 15:22:35 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/149462.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Sep 2023 16:22:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can&#x27;t paint over QVideoWidget in Qt6 on Tue, 12 Sep 2023 21:13:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> Ok thanks! I will try to do that but I am really not an expert :)</p>
]]></description><link>https://forum.qt.io/post/772525</link><guid isPermaLink="true">https://forum.qt.io/post/772525</guid><dc:creator><![CDATA[MartCh]]></dc:creator><pubDate>Tue, 12 Sep 2023 21:13:16 GMT</pubDate></item><item><title><![CDATA[Reply to Can&#x27;t paint over QVideoWidget in Qt6 on Tue, 12 Sep 2023 19:05:05 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">The architecture of the multimedia module has greatly changed for Qt 6.</p>
<p dir="auto">Taking a quick look at the QVideoWidget implementation, the RHI backend is used by default which means that OpenGL will be used for rendering unless it cannot initialize any of the accelerated backends.</p>
<p dir="auto">AFAIR, you have to implement your own <a href="https://doc.qt.io/qt-6/qvideosink.html" target="_blank" rel="noopener noreferrer nofollow ugc">QVideoSink</a> to modify the frame.</p>
]]></description><link>https://forum.qt.io/post/772516</link><guid isPermaLink="true">https://forum.qt.io/post/772516</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 12 Sep 2023 19:05:05 GMT</pubDate></item></channel></rss>