QGraphicsView, QGraphicsScene item coordinates in scene
Hi,
i have some trouble retrieving an item's position in scene coordinates.
currently the code looks like:
Code:
{
if (event->button()==Qt::LeftButton)
{
Vertex
::Vertex* vertex
= new Vertex
::Vertex(QRect(event
->x
(), event
->y
(),
2,
2));
vertex->setZValue(3);
m_scene->addItem(vertex); // QGraphicsScene*
std::cout << "Pos: " << vertex->pos().x() << " : " << vertex->pos().y() << std::endl;
}
}
but pos() always returns 0:0. i have read the documentation and tried a lot of things (setPos,mapToScene, scenePos..) but always retrieve a wrong or zero position.
which function do i have to call to retreive the coordinates set by event->x(), event->y() ?
thanks in advance
Re: QGraphicsView, QGraphicsScene item coordinates in scene
Re: QGraphicsView, QGraphicsScene item coordinates in scene
use mouseEvent->scenePos().rx() and mouseEvent->scenePos().ry() instead of mouseEvent->pos()