QGraphicsScene::mouseMoveEvent Question
hi, i have a QGraphicsScene in a QGraphicsView:
Code:
view = new GraphicsView( this );
scene = new GraphicsScene( this );
scene->setSceneRect( 0.0, 0.0, 512.0, 512.0 );
scene->add....(...
....
view->setScene( scene );
view->show();
all objects added to the scene are displayed correctely, but
Code:
cout << " moved to: X->" << event->pos().toPoint().x();
cout << " moved to: Y->" << event->pos().toPoint().y() << endl;
event->accept();
}
always results in X->0 and Y->0
why is that so?
Re: QGraphicsScene::mouseMoveEvent Question
What does:
Code:
cout << " moved to: X->" << event->pos().x();
cout << " moved to: Y->" << event->pos().y() << endl;
output?
Re: QGraphicsScene::mouseMoveEvent Question
...
moved to: X->0 moved to: Y->0
moved to: X->0 moved to: Y->0
moved to: X->0 moved to: Y->0
moved to: X->0 moved to: Y->0
...
:-(
Re: QGraphicsScene::mouseMoveEvent Question
Use event->scenePos()
event->pos() is used to represent mouse coords in terms of item So it will be 0 when you use it in scene's mouse event.