Why does QGraphicsItem::scenePos() return (0,0)
Hi all,
I am trying to implement a drawing canvas with QGraphicsView and QGraphicsScene. What is perplexing is that after I add a new item to the scene, it's scenePos() is always (0,0). As a trial I test out the following code:
Code:
qDebug() << anotherLine->scenePos();
qDebug() << anotherLine2->scenePos();
Where the this pointer is a class derived from QGraphicsScene. The output for both line is QPointF(0,0).
To my understanding, scenePos() should be returning the position of the QGraphicsItem within the scene itself, but right now it is acting as if it is returning the origin of the item within its own local coordinate. What am I doing wrong?
Re: Why does QGraphicsItem::scenePos() return (0,0)
and pos() value returns ..?
Returns the position of the item in parent coordinates.
Re: Why does QGraphicsItem::scenePos() return (0,0)
Quote:
Originally Posted by
wagmare
and pos() value returns ..?
Returns the position of the item in parent coordinates.
It still returns QPointF(0,0)...
Re: Why does QGraphicsItem::scenePos() return (0,0)
I realise my mistake. I should be doing this instead:
Code:
// Length/angle of line
// Move it to where i want it to be inside the scene
newLine->setPos(50,50);