I have a problem with determining position of QGraphicsLineItem
. I want to move items on the scene relatively, so I need to know their position. I have few QGraphicsPixmapItem
objects and I do not have problem with them because pixmapItem.pos()
gives me realistic position of every item in scene coordinates. But with QGraphicsLineItem
s i get the same coordinate (0,0) for every line. Here is code:
QGraphicsLineItem*line = new QGraphicsLineItem();
scene->addItem(line);
line->setLine(QLineF(0,VVR-i*(OH),HVR,VVR-i*(OH)));
This code draws lines in correct position, but its coordinates are set to (0,0)
not to (0,VVR-i*(OH))
.
The following code should move the line item by (VVR + OH) when it reaches position greater than VVR. But since all lines have starting position (0,0), wherever I put them, all lines are moved at the same time.
QPointF current_pos = line->pos();
if (current_pos.y() >= VVR)
{
line->setPos(current_pos.x(),current_pos.y()-(VVR+(OH)));
}
How can I get the real (scene) coordinates of the QGraphicsLineItem
, as I get for QGraphicsPixmapItem
Thanks!