Hello,

I upgraded from Qt 4.8 to 5.4 and I noticed odd behaviors of my gui application. I'm using the graphics view framework and my setup is the standard items in a scene in a graphics view layout. The first thing I noticed is that my QGraphicsRectItems are now suddenly huge compared to before. I use the setRect() method in the constructor to define the size like so:

Qt Code:
  1. Foot::Foot(QGraphicsItem *parent)
  2. {
  3. setRect(-0.05, -0.035, 0.1, 0.07);
  4. }
To copy to clipboard, switch view to plain text mode 

It seems that now the setRect() methods add to the default size rather than replacing it, such that I have to subtract a unit rectangle to get the same size I intended before like so:

Qt Code:
  1. Foot::Foot(QGraphicsItem *parent)
  2. {
  3. setRect(-0.05 +0.5, -0.035 +0.5, 0.1 -1, 0.07 -1);
  4. }
To copy to clipboard, switch view to plain text mode 

Is this intended behavior or a bug?


The second thing I noticed is that the item discovery seems to be broken. The attached screenshot Screenshot from 2015-04-22 14:58:11.jpg was produced by the following code in my graphics view:

Qt Code:
  1. class GraphicsViewWidget : public QGraphicsView {...}
  2.  
  3. void GraphicsViewWidget::drawForeground(QPainter* painter, const QRectF& rect)
  4. {
  5. painter->resetTransform(); // The painter draws in scene coordinates by default. We want draw in view coordinates.
  6.  
  7. // Item detector.
  8. QGraphicsScene* sc = scene();
  9. for (int i = 0; i < width(); i+=5)
  10. {
  11. for (int j = 0; j < width(); j+=5)
  12. {
  13. int itemCount = sc->items(mapToScene(i,j)).size();
  14. if (itemCount > 0)
  15. painter->drawEllipse(i, j, itemCount, itemCount);
  16. }
  17. }
  18. }
To copy to clipboard, switch view to plain text mode 

The above code draws a dot at the view coordinates where at least one item was found in the scene. All items in the scene are covered by dots, but also a lot of places where there are no items. When I use the QGraphicsView::items() method, the item discovery works perfectly. QGraphicsScene::items() seems to be broken, however, and it has implications to the UI. The dotted areas respond to the mouse and the scene / the items believe that the mouse is on the item, which is not true. To me this clearly looks like a bug, but in any case, what can I do to fix this?

Cheers,
Cruz