Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot display QVideoWidget when TranslucentBackground is on and cannot disable TranslucentBackground ?
Forum Updated to NodeBB v4.3 + New Features

Cannot display QVideoWidget when TranslucentBackground is on and cannot disable TranslucentBackground ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 275 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shiyuu
    wrote on 30 Aug 2020, 04:14 last edited by Shiyuu
    #1

    I am on Windows 10 using Qt5 in Mingw.
    I have a Hierarchy of QMainWindow > QWidget (=centralWidget) > QVBoxLayout > Content.

    The Content depends on which file the user opens. If it is an image file, Content is a subclass of QLabel and 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

    setAttribute(Qt::WA_TranslucentBackground);
    

    in my QMainWindow subclass to achieve this.

    If the user instead opens a video file, I want Content to be a different widget, which is a subclass of QVideoWidget with a QMediaPlayer member 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 WA_TranslucentBackground active, the QVideoWidget does 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:

    • before show() / hide() call setAttribute(Qt::WA_TranslucentBackground, false); - this does not seem to do anything
    • do not call setAttribute(Qt::WA_TranslucentBackground); for QMainWindow, but for Content instead, only in the image case - this does not work: the images are not shown transparent
    • instead of hide() / show(), use removeWidget(... / addWidget(... on the QVBoxLayout - again this does nothing, both of the first two points show the same behavior
    • instead of hide() / show(), delete and new the different Content s - still does nothing, same behavior as above

    At this point I am stuck. Why does Qt show the videos completely transparent when WA_TranslucentBackground is active? Is there any way to fix this? Alternatively, how do I dynamically enable / disable WA_TranslucentBackground properly, as setAttribute(..., false); seems to do nothing?

    1 Reply Last reply
    0

    1/1

    30 Aug 2020, 04:14

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved