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

QPen setCosmetic does not work in high QGraphicsView scale

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.11.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      MSVC 2017, QtCreator 5.8
    • Platform/s:
      Windows

      Description

      I have a QGraphicsView and a QGraphicsItem that added to graphicsView's scene. I override QGraphicsView wheelEvent to do scale view, but i want my graphics item width does not change.

      For this purpose i set cosmetic true for pen in graphics item paint function. it is work fine but after some scale in (zoom), cosmetic feature does not work and graphics item width begins to grow up for more zoom (like cosmetic set to false) when i setup setViewport(new QGLWidget) in MyGraphicsView.

      Scale code is like so:

      void MyGraphicsView::WheelEvent(QWheelEvent* e)
      {
          auto z = pow(2, e->delta() / 120 / 4);
          scale(z, z);
      }

      Graphics item override paint function is like so:

      void MyGraphicsItem::paint(QPainter* p, ...)
      {
          QPen pen;
          pen.setColor(Qt::Black);
          pen.setCosmetics(true);
          painter.setPen(pen);
          painter.drawLine(somePoint1, somePoint2);
      }
      

       

        Attachments

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

          Activity

            People

            • Assignee:
              vgt Eirik Aavitsland
              Reporter:
              drspam Mohsen Sh
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Gerrit Reviews

                There are no open Gerrit changes