Hi,

I have an outer QGraphicsRectItem and inner QGraphicsRectItem, where the outerRec is the parent of innerRect. When I do setRect, I would expect the rect is in respect to its parent item, but it is not the case, as shown in the example, where the red innerRect is outside its container and its position is related to the scene. Is this a bug? If it is a feature, then why not use setSize + translate? Currently the outerRect's rect has no meaning to the innerRect..

Qt Code:
  1. #include <QApplication>
  2. #include <QGraphicsScene>
  3. #include <QGraphicsView>
  4. #include <QGraphicsRectItem>
  5.  
  6. int main( int argc, char** argv )
  7. {
  8. QApplication app(argc, argv);
  9.  
  10. scene.setSceneRect( 0, 0, 500, 500 );
  11.  
  12. QGraphicsRectItem outerRect;
  13. outerRect.setRect( QRectF( 20, 20, 400, 400 ) );
  14.  
  15. QGraphicsRectItem innerRect;
  16. innerRect.setRect( QRectF( 0, 0, 200, 400 ) );
  17. innerRect.setParentItem( &outerRect );
  18. innerRect.setPen( QPen( Qt::red ) );
  19.  
  20. scene.addItem( &outerRect );
  21.  
  22. QGraphicsView view(&scene);
  23.  
  24. view.show();
  25.  
  26. return app.exec();
  27.  
  28. }
To copy to clipboard, switch view to plain text mode