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

[Reg 5.6.2->5.7.0] QGraphicsView - drawing happens outside the boundaries of a widget



    • Commits:
      eef70912bf7b0d25c07122f39cc8f819c6e351eb (qtbase/5.9, 3.8.2017, 5.9.2)


      The attached source code represents a minimal repeatable case.
      The case is the following:
      QMainWindow contains QGraphicsView as a center widget.
      The are also dock widgets with QTreeViews.

      The redraw problem is easily reproducible if you grab either left or right dock widget's resize bar and start moving it.
      On the real project it also occurs when window becomes inactive.

      The issue is caused by the push button widget. It occurs only if it is visible in the view. If you scroll the view and hide it, everything is ok.
      An important factor is that the button lies before all other elements on the scene (in terms of Z-order). And incorrect drawing occurs only for the items that lie after.
      Also note that the text is drawn as a polygon, not as spline or something. Maybe that will help in discovering the problem.

      The issue is not reproduced in Qt 5.6 and earlier.

      Here is fragment of source code:

      #define WIDTH 200
      #define HEIGHT 100
      void MainWindow::PopulateScene()
          //Important condition - widget should be before all other items (Z-order)
          auto pButton = new QPushButton("Button");
          auto pButtonProxy = m_pScene->addWidget(pButton);
          pButtonProxy->setPos(WIDTH * 10, HEIGHT * 10);
          for (size_t i = 0; i < 20; i++)
              for (size_t j = 0; j < 20; j++)
                  // Text is big enough to cover the entire rectangle
                  auto pRect = m_pScene->addRect(QRectF(0, 0, WIDTH, HEIGHT));
                  auto pText = m_pScene->addSimpleText("LongText");
                  auto qFont = pText->font();
                  pRect->setPos(j * WIDTH, i * HEIGHT);


        1. qtbug56282_diag.diff
          3 kB
        2. qtbug56282.zip
          3 kB
        3. RedrawIssue.png
          199 kB
        4. RedrawIssue.zip
          5 kB

          Issue Links

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



              • Assignee:
                kleint Friedemann Kleint
                cadmiy Artyom Chirkov
              • Votes:
                1 Vote for this issue
                4 Start watching this issue


                • Created:

                  Gerrit Reviews Side Panel

                  Error rendering 'com.meetme.plugins.jira.gerrit-plugin:gerrit-reviews-side-panel'. Please contact your Jira administrators.