PDA

View Full Version : Cann't move movable items on custom graphics view



wojtekw
3rd March 2008, 19:21
Hi,
I'm drawing QGraphicsEllipseItem on QGraphicsScene viewed through MyGraphicsView subclassed from QGraphicsView (mouse events are reimplemented to handle zoom in/out by right-click-drag-release).
The item is supposed to be movable (setFlag(QGraphicsItem::ItemIsMovable,true)) but I cannot move it.

I'm attaching simple code to illustrate the problem.

What am I missing?
Wojtek

jpn
3rd March 2008, 19:36
You must call the base class implementation in your re-implemented mouse event handlers to let the view know about received events.



void MyGraphicsView::mousePressEvent( QMouseEvent *e )
{
...
QGraphicsView::mousePressEvent(e); // <---
...
}

wojtekw
3rd March 2008, 21:30
Big thanks jpn!
wojtek