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

HighDpi: Artifacts in drawn frames

    XMLWordPrintable

Details

    • b6d5026b1f8d7ed6424f9a395d47fc4c62d4751b (qtbase/5.9, 7.7.2017, 5.9.2.)

    Description

      QFrame with FusionStyle, WindowsStyle (and other styles), or anything that calls qDrawPlainRect() has painting artifacts in the left and top, when in scaled/HighDpi mode.

      The lines are too thin, perhaps clipped. The reason seems to be the typical off-by-one of code that was written for normal resolution usinf the integer QPainter-API.

      Some adjustments like the following one fix the issue. However, that needs to be thoroughly tested, especially to prevent regressions in the unscaled mode.

      --- a/src/widgets/styles/qdrawutil.cpp
      +++ b/src/widgets/styles/qdrawutil.cpp
      @@ -520,10 +520,12 @@ void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
           }
           QPen   oldPen   = p->pen();
           QBrush oldBrush = p->brush();
      -    p->setPen(c);
      +    QPen   newPen(c);
      +    newPen.setJoinStyle(Qt::MiterJoin);
      +    p->setPen(newPen);
           p->setBrush(Qt::NoBrush);
           for (int i=0; i<lineWidth; i++)
      -        p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
      +        p->drawRect(QRectF(x+i + 0.5, y+i + 0.5, w-i*2 - 1, h-i*2 - 1));
           if (fill) {                                // fill with fill color
               p->setPen(Qt::NoPen);
               p->setBrush(*fill);
      -- 
      

      Attachments

        Issue Links

          Activity

            People

              kleint Friedemann Kleint
              portale Alessandro Portale
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: