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

Painting outside of graphics view when qgraphicsproxywidget instantiated in Qt 5.7




      Items within a graphics view get partially drawn outside the view on the remainder of the main application window, nasty. So far it doesn't seem to cause any crashes, but it makes the application completely unusable, this issue should have high priority. Also, this problem does not manifest in Qt 5.6 (binary distribution from your website).

      The following C++ code reproduces the problem: shows an ellipse drawn in a graphics view, and the ellipse is partly drawn outside the view! As long as there is more than one proxy widget in the scene, the bug appears:

      #include <QApplication>
      #include <QtCore>
      #include <QtWidgets>
      #include <QtGui>
      class MyGraphicsItem: public QGraphicsObject
              // next line could be any type of graphics item:
              QGraphicsEllipseItem* rect_item = new QGraphicsEllipseItem(0, 0, 100, 100, this);
              // effect easier to see if paint black:
              QGraphicsProxyWidget* label_item = new QGraphicsProxyWidget(this);
              // *** Next line must be there for effect to be visible, but could be any other type of widget
              label_item->setWidget(new QLabel("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
          QRectF boundingRect() const Q_DECL_OVERRIDE
              return childrenBoundingRect();
      int main(int argc, char *argv[])
          QApplication app(argc, argv);
          QWidget widget;
          QHBoxLayout* layout = new  QHBoxLayout();
          QGraphicsView* view = new QGraphicsView();
          QGraphicsScene* scene = new QGraphicsScene();
          scene->addItem(new MyGraphicsItem());  // *** effect only there if more than 1 item
          scene->addItem(new MyGraphicsItem());
          widget.setGeometry(100, 100, 50, 50);
          return app.exec();

      Setting the opacity of label_item to just below 1 (like 0.9999) gets rid of the problem

      The fact that this is a regression, and that opacity < 1 works fine, likely make this bug really easy to figure out, but I'm not familiar enough with Qt to track it down and I don't have access to a C++ dev env here (I use Qt from Python only). I bet that some different logic gets executed when opacity is 1, as an optimization because that's the most common case, whereas opacity < 1 requires some blending which has a cost and hence associated code not run when opacity = 1.

      This bug is probably related to 55070 but I wanted to produce a separate bug report since it is different code, and really this should have higher than P3 priority given the impact and the ease with which it is likely to be resolved.


          Issue Links

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



              mmutz Marc Mutz
              schollii schollii
              2 Vote for this issue
              11 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes