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

QGraphicsEllipseItem::boundingRect gives a wrong answer if QPenPrivate::cosmetic is 1

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 6.2.4
    • Widgets: GraphicsView
    • None
    • All

    Description

      Consider the following code:

      auto pen = QPen{{{ 93, 109, 194}}, 5};
      pen.setCosmetic(true);
      auto c = new QGraphicsEllipseItem{{-0.2, -0.2, 0.4, 0.4}};
      c->setPen(pen);
      auto boundingRect = c->boundingRect();
      printf(
          "boundingRect = {.x = %lg, .y = %lg, .width = %lg, .height = %lg }\n",
          boundingRect.x(), boundingRect.y(),
          boundingRect.width(), boundingRect.height());
      

      The output is

      boundingRect = {.x = -2.7, .y = -2.7, .width = 5.4, .height = 5.4 }
      

      i.e. 13.5 larger than the actual bounding rectangle. The culprit is QGraphicsEllipseItem::boundingRect, which assumes the pen width is in the scene units.

      Attachments

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

        Activity

          People

            bibr Andreas Aardal Hanssen
            dreghor Pavel Baxtin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes