Each graphics item has initial position at (0, 0)
. You can set its new position using setPos
. All its contents will be shifted according to new position.
But setLine
doesn't change item position. This method change the object the item represents instead. For example, an object can be (0, 5) - (5, 5)
line. If you didn't set item position, the position remains at (0, 0)
and the line is shown at (0, 5) - (5, 5)
. If you set e.g. position (2, 0)
, the line will be shifted to (2, 5) - (7, 5)
position. There are methods similar to setLine
in other basic graphics item classes (e.g. QGraphicsPixmapItem::setOffset
).
If you want to get the line position that was set previously by setLine()
, use line()
method. If you shifted the item using setPos()
, use pos()
.
Additionally, since you said that you want to move items on the scene relatively, I'd like to mention the following fact. If you set a parent item for an item, its position will be calculated relatively to the parent item. You might find it useful.