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

QPainter artifacts when scale() and antialiasing is used

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.0.0
    • 6.0.0 Beta5
    • GUI: Painting
    • None
    • Windows 10 Professional 64bit latest version
      Arch Linux -> KDE Plasma 5.20.3 desktop environment
      Screen Resolution 2560 x 1440
    • Linux/X11, Windows
    • a31484302d71c29c0e0e62f9941f9d5f0c87f9aa (qt/qtbase/dev) 9379e47831bd634aa046cf9a21542371ddde5c66 (qt/qtbase/6.0.0) c0b0ade6223c7ed492069f2fe0d801b4a5893e3d (qt/qtbase/6.0)

    Description

      Drawing lines with QPainter:drawLine() can lead to artifacts if QPainter:scale() is used in combination with QPainter:setRenderHints(QPainter::Antialiasing, true).
      Removing either QPainter::Antialiasing or QPainter:scale() eleminates the drawing artifacts.

      This is a regression: Qt 5.15.2 and prior versions doesn't show this issue.

      Example code:

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>
      
      class Widget : public QWidget
      {
      protected:
          void paintEvent(QPaintEvent *)
          {
              QPainter painter(this);
              painter.setRenderHints(QPainter::Antialiasing, true);
      
              const auto Width = width();
              const auto Height = height();
              const auto Side = qMin(Width, Height);
              painter.scale(Side / 600.0, Side / 600.0);
      
              painter.drawLine(QLineF(490.05, 100.0, 490.1, 50.0));
          }
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          w.show();
          return a.exec();
      }
      1. This example application draws a single vertical line.
      2. After executing the application move its window to the upper left corner of the screen.
      3. Then slowly enlarge the application window by dragging the bottom right corner of the application window using the mouse.
      4. Then at some point a not intended horizontal line shows up - which is a bug.

      Attachments

        Activity

          People

            allan.jensen Allan Sandfeld Jensen
            mireiner Chris
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: