Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Cannot display QVideoWidget when TranslucentBackground is on and cannot disable TranslucentBackground ?
Shiyuu last edited by Shiyuu
I am on Windows 10 using Qt5 in Mingw.
I have a Hierarchy of
QMainWindow > QWidget (=centralWidget) > QVBoxLayout > Content.
Contentdepends on which file the user opens. If it is an image file,
Contentis a subclass of
QLabeland shows the image with any transparent parts completely see-through, i.e. any background windows or the desktop can be seen. I have this working and use
QMainWindowsubclass to achieve this.
If the user instead opens a video file, I want
Contentto be a different widget, which is a subclass of
QMediaPlayermember that plays the video. The playback itself also works. I do not care to show the videos transparent like the images. Videos can be fully opaque.
However, my problem is that with
QVideoWidgetdoes not show up at all, it is completely transparent, and I cannot see anything except the taskbar entry of my application.. even if the video is not transparent. If I do not set
WA_TranslucentBackground, then the video shows, but the images are (of course) no longer shown transparent.
I tried many different things to try and resolve the issue, but nothing works:
setAttribute(Qt::WA_TranslucentBackground, false);- this does not seem to do anything
- do not call
QMainWindow, but for
Contentinstead, only in the image case - this does not work: the images are not shown transparent
- instead of
QVBoxLayout- again this does nothing, both of the first two points show the same behavior
- instead of
Contents - still does nothing, same behavior as above
At this point I am stuck. Why does Qt show the videos completely transparent when
WA_TranslucentBackgroundis active? Is there any way to fix this? Alternatively, how do I dynamically enable / disable
setAttribute(..., false);seems to do nothing?