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. QWidget is not transparent when being used as a subcontrol
Forum Updated to NodeBB v4.3 + New Features

QWidget is not transparent when being used as a subcontrol

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 462 Views 2 Watching
  • 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.
  • G Offline
    G Offline
    gaojinhsu
    wrote on last edited by gaojinhsu
    #1

    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
    7e3cc2cc-2697-4290-ac3e-c5f60481acf2-image.png

    when we remove the third-party SDK related code
    8aabad28-719e-42af-9715-6bf454aa15b0-image.png

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gaojinhsu
      wrote on last edited by gaojinhsu
      #4

      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.

      1 Reply Last reply
      0
      • Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by
        #2

        @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,


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        G 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @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,

          G Offline
          G Offline
          gaojinhsu
          wrote on last edited by
          #3

          @Pl45m4 The widget whose HWND was given to the SDK, and my rounded rectangle widget are brother controls. they have a same parent widget. that's the most strangest thing.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gaojinhsu
            wrote on last edited by gaojinhsu
            #4

            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.

            1 Reply Last reply
            0
            • G gaojinhsu has marked this topic as solved on

            • Login

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