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

QPainter::drawLine() for multiple times, some lines have incorrect width.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 6.8.0
    • GUI: Painting
    • None
    • windows 10, VS2022
    • Windows

    Description

      run QPainter::drawLine() on QWidget for multiple times, we set the pen width to 1, but some lines have the width 2.

      This problem only exists in Qt 6 version, I tested it with Qt 5.15.2, no such problem.

      test code:

      void QWidgetMain::paintEvent(QPaintEvent*)
      {
          QPainter Painter(this);
          
          QPen MyPen;
          MyPen.setColor(QColor(250, 20, 20));
          MyPen.setWidth(1);
          Painter.setPen(MyPen);

          for (int i = 0; i < width(); i += 3)
         

      {         Painter.drawLine(i, 50, i, 200);     }

          for (int i = 250; i < 400; i += 3)
         

      {         Painter.drawLine(50, i, 200, i);     }

      }

      Test result was uploaded to attachment.

      Attachments

        1. qt5.15.2.png
          qt5.15.2.png
          2 kB
        2. qt6.8.0.png
          qt6.8.0.png
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vgt Eirik Aavitsland
            wujian_mail wujian_mail
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes