Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113456

Window background cannot be transparent.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 6.5, dev
    • Quick: Widget
    • None
    • Windows
    • fd56ad806 (dev), 941fb88d0 (6.6), 5a85af7e0 (6.5)

    Description

      I thought it might be the same as the following issue, but I can't solve it.

      https://bugreports.qt.io/browse/QTBUG-112473

       

      I using Qt 6.6 dev on Windows 10/11.

      And developing Qt Qucik application.

       

      Part of code:
      ApplicationWindow {
          id: root
          width: 640
          height: 480
          visible: true
          color: "transparent"

      I set color to transparent. 

      I expected the background to be transparent, but it was drawn white.

       

      So I added the following code:

          MyUtils

      {         id: myutils     }

          onVisibleChanged:

      {         myutils.fillBackgroundBlack()     }

      and

      void MyUtils::fillBackgroundBlack()

      {     QWindowList wins = QGuiApplication::topLevelWindows();     if (wins.empty()) return;     HBRUSH hbrush = CreateSolidBrush(RGB(0, 0, 0));     HWND hwnd = (HWND)wins[0]->winId();     RECT rc;     GetClientRect(hwnd, &rc);     HDC hdc = GetDC(hwnd);     FillRect(hdc, &rc, hbrush);     ReleaseDC(hwnd, hdc);     DeleteObject(hbrush); }

       

      This way I was able to make the window transparent by forcing the background to be filled with black.

       

      I would expect to be able to make the background transparent without any special hacks like this.

       

      This problem has been occurring since the following fix.

      https://codereview.qt-project.org/c/qt/qtbase/+/421952

       

      expected:

      actual:

       

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-113456
          # Subject Branch Project Status CR V

          Activity

            People

              tvete Paul Olav Tvete
              shinichi_fuchita shinichi_fuchita
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes