3

In an application I'm writing for Linux, I have a QWidget backed by a native window (video, rendered to via libmpv) on which I want to overlay another (transparent) QWidget, which will be used for drawing over the video.

I tried placing them both into a containing QWidget with a QStackedLayout (using StackAll mode), however this causes the native window content updates to not be reflected in the application, even if I set Qt::WA_NativeWindow on the containing widget so that the container and all its children (the overlay and the video widget) are created as native windows.

The native window does properly get updated if the overlay widget isn't present, so there's no problem on that end. The overlay widget itself also has no issues, as it shows up only partially covering the video widget area as expected.

In the past I've written something similar using Gtk+, where I solved this by using gdk_window_set_composited, which causes the video widget to be rendered offscreen and the parent widget be notified whenever the child updates so that it can handle drawing the child contents itself. However, I was unable to find anything equivilant in Qt, so I'm at a loss at how to achieve this.

Using QOpenGLWidget is not an option, as libmpv has issues where the video rendering slows to a crawl if the current workspace is switched during playback.

sagara
  • 31
  • 2

0 Answers0