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

Bad QTextDocument rendering when using QPixmap with Qt::transparent fill and QT_XCB_NATIVE_PAINTING set

    XMLWordPrintable

Details

    • Linux/X11

    Description

      Ever since I upgraded an application to Qt5 I have seen bad rendering on some user environments, where the fill with Qt::transparent combined with the QT_XCB_NATIVE_PAINTING set to 1. seems to behave badly and not do proper antialising.

      Take this sample code which is supposed to just open a window with a Hello printed:

      #include <QtCore/QString>
      #include <QtGui/QColor>
      #include <QtGui/QPainter>
      #include <QtGui/QPixmap>
      #include <QtGui/QTextDocument>
      #include <QtWidgets/QApplication>
      #include <QtWidgets/QLabel>
      #include <QtWidgets/QMainWindow>
      #include <QtWidgets/QWidget>
      
      
      QPixmap getPixmap()
      {
          QTextDocument text;
          text.setPlainText("Hello");
      
          QPixmap pm(100, 100);
          pm.fill(Qt::transparent);
      
          QPainter painter(&pm);
          text.drawContents(&painter, pm.rect());
      
          return pm;
      }
      
      int main(int argc, char** argv)
      {
          QApplication app(argc, argv);
          QMainWindow mw;
          QLabel dummyLabel;
          QFont f = dummyLabel.font();
          f.setStyleStrategy(QFont::NoSubpixelAntialias);
          dummyLabel.setFont(f);
          dummyLabel.setPixmap(getPixmap());
          mw.setCentralWidget(&dummyLabel);
          mw.show();
          return app.exec();
      }
      
      

      Here's how it looks on a RHEL8 machine without QT_XCB_NATIVE_PAINTING set:

      Here's how it looks on some RHEL8 machine with QT_XCB_NATIVE_PAINTING set to 1:

      I did debug, but couldn't get to the conclusion of what is to blame. Some of what I investigated:

      1. SSHing into a VM where an user reports the issue ("buggy" VM) does not reproduce it, only when running directly from the VM
      2. SSHing into a non-buggy machine from the "buggy" VM does not reproduce the issue
      3. This did not happen on Qt 4.6 (I know QT_XCB_NATIVE_PAINTING didn't exist back then, but then it was also the default)
      4. Users that get this bug can reproduce it from their VMs in RHEL8/RHEL7/CentOS7 etc, seems to be tied to how the display is setup or something they might have installed

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            tupaschoal Tulio Leao
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes