bq. Rectangles are drawn when you release the mouse button. I want rectangles to be shown when moving the mouse.
Your last sentence is quite unlogical...
If you want to see anything, you have to draw it. If you want to draw, when you move your mouse, use that event as I mentioned above. On painting it uses paintEvent...but...
You are not allowed to draw in QGraphicsScene, because it's just map (what come where, and what will stay at top, and so on...), it's not a widget, you have to draw in @void QGraphicsItem::paint()@ or in @QGraphicsView::paintEvent(...)@ , which gives painter to all used objects/items (QGraphicsItem through paint() method)
My advice is: You shouldn't work in QGraphicsScene but in QGraphicsView, it'll be better...And even better will be, to work in QGraphicsItem...
Best wishes...