QWidget is not transparent when being used as a subcontrol
-
As we all know, QWidget is transparent by default while being used as a subcontrol, but in my project, it is not. So far, we can draw the conclusion that it is because we called an API provided by a third-patry SDK which is closed-source. We don't know what it has done inside, we just give another widget's HWND to it and it will render video for us. I've googled a lot, but setting QSS would not work, Anybody can give me a clue how to fix it? Thanks in advance.
here is the screenshot of the issue
when we remove the third-party SDK related code
-
Transparency in Windows is achieved through layered windows, which is also used in Qt's transparent window and belongs to DirectUI. The entire window has only one winId (HWND) but OpenGL and DirectX require a handle to render. However, if a child widget in the Qt window obtains the winId, it will break the "DirectUI" and all widgets in the window will have a handle. Therefore, it is impossible to render a specific widget with OpenGL or DirectX in a transparent window.
The solution : Set the controls on top of the video to be Tooltip + transparent background. Additionally, when a control is set as a tooltip, its coordinates are no longer relative to the parent window but global. Therefore, special handling is required for its coordinates. -
@gaojinhsu said in QWidget is not transparent when being used as a subcontrol:
we just give another widget's HWND to it
I think, the third party program has a given size and the space it takes to render the content is not transparent. So it might comes from the SDK HWND.
Maybe you can check the third party documentation, if any, -
@gaojinhsu said in QWidget is not transparent when being used as a subcontrol:
we just give another widget's HWND to it
I think, the third party program has a given size and the space it takes to render the content is not transparent. So it might comes from the SDK HWND.
Maybe you can check the third party documentation, if any, -
Transparency in Windows is achieved through layered windows, which is also used in Qt's transparent window and belongs to DirectUI. The entire window has only one winId (HWND) but OpenGL and DirectX require a handle to render. However, if a child widget in the Qt window obtains the winId, it will break the "DirectUI" and all widgets in the window will have a handle. Therefore, it is impossible to render a specific widget with OpenGL or DirectX in a transparent window.
The solution : Set the controls on top of the video to be Tooltip + transparent background. Additionally, when a control is set as a tooltip, its coordinates are no longer relative to the parent window but global. Therefore, special handling is required for its coordinates. -