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

Adding a QGraphicsPixmapItem with ItemIgnoresTransformations causes sceneRect to extend to 0,0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 4.6.2, 4.6.3, 4.7.2
    • Widgets: GraphicsView
    • None

      If you add a QGraphicsPixmapItem with the QGraphicsItem::ItemIgnoresTransformations flag set, it will cause the parent QGraphicsScene's sceneRect to extend to 0,0 even when the pixmap item is no where near (0,0) and no other item is located near 0,0.

      The QGraphicScene sceneRect is failing to take in to account the position of the pixmap relative to the graphicsScene when uniting the sceneRect with the pixmapItem.boundingRect().

      The attached sample app demonstrates this problem. Click the "add pixmap" button to add a QGraphicsPixmapItem to the QGraphicsScene. All items on the QGraphicsScene are located above 1000,1000 (including the pixmap). When the pixmap is added the sceneRect extends to 0,0 causing all the items to disappear off screen. MainWindow.cpp contains the code that populates the graphics scene and the addPixmap slot.

      A simple workaround is to call graphicsSene.setSceneRect( graphicsScene.sceneRect() ) - see the code inside the "BOUNDINGRECT_WORKAROUND" ifdefs.

      The same problem can also be reproduced with other QGraphicsItems when the ItemIgnoresTransformations flag is set. The MainWindow::addEllipse function demonstrates this if QGraphicsEllipseItem::setRect is used to create an ellipse at 0,0 which is then moved by a call to setPos. SetPos is called before the item is added to the parent scene.

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

            Unassigned Unassigned
            mr_andrew_brown Andrew Brown
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes