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

[Regression] Settings a QPixmap larger than screen size to a QBrush/QPalette is broken.

    XMLWordPrintable

Details

    Description

      Using a QPixmap to paint the background of a window could be done by setting the QPixmap to the texture of a QBrush, and then set the QBrush to the QPalette. This is broken in newer versions of Qt 5 if the pixmap is larger than current screen size in a XRANDR multi-monitor setting.
      The attachment contain a test case to reproduce this bug.

      Widget::Widget() {
          QScreen* screen = qApp->primaryScreen();  // make the window as large as the virtual screen
          setGeometry(screen->availableVirtualGeometry());
          QImage img("numix.png");  // resize the image to the virtual screen size
          QPixmap pix = QPixmap::fromImage(img.scaled(screen->availableVirtualSize()));
          QBrush b(pix);
          QPalette p(palette());
          p.setBrush(QPalette::Window, b);  // use the image to paint the window background
          setPalette(p);
      }
      

      I have two monitors with the resolution 1920x1200. Side-by-side, they can form a large virtual screen with the size of 3840 x 1200.
      In the code I set a 3840 x 1200 QPixmap to a QBrush, and use that QBrush to paint a window whose size is also 3840 x 1200.
      The expected result should be like "expected.png", the window background is filled by the 3840x1200 pixmap.
      However, the actual result is "actual.png", in which the QPixmap is clipped and only the left part (1920x1200) is used as the texture pattern and it's repeated twice.

      This never happened in earlier Qt 4.8 and 5.4 versions. So I guess it's a regression bug. Please help fix this.
      This bug breaks the desktop icon manager of the LXQt desktop environment.
      Reported in LXQt bug tracker by many users. https://github.com/lxde/lxqt/issues/1027

      Attachments

        1. actual.png
          actual.png
          225 kB
        2. expected.png
          expected.png
          243 kB
        3. qbrush_bug.tar.gz
          1.38 MB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            paeglis Gatis Paeglis
            pcman Hong Jen Yee
            Votes:
            10 Vote for this issue
            Watchers:
            12 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes