Hi all, I'm new QT so please excuse the following if it's obvious.

There seems to be two item-based coordinate systems for QGraphics items (at least for translations) and they seem to be independent and have a cumulative effect. One you can access via setPos(), moveBy() etc the other via translate() etc by setting the transform matrix.

I've read in other posts that translate() is only provided for "completeness" and we should use pos() and setPos(), and in the API docs that translate and moveBy are "conceptually separate" . I'm of a mathematical bent and I like affine transforms. I want to set up complex nested transformations which just amounts to matrix multiplication for the affine coordinate system, but it would be a real pain to have to set all movements in a separate co-ordinate system from scaling and rotations ...

Here is an example (it's pyqt but should be clear)...

I've created an item in a scene, initially the scenePos and pos are the same:

>>> self.scenePos()

>>> self.pos()

>>> self.scenePos()
PyQt4.QtCore.QPointF(10.0, 10.0)
>>> self.pos()
PyQt4.QtCore.QPointF(10.0, 10.0)

*To copy to clipboard, switch view to plain text mode *

the translation shows 0,0:

>>> t=self.transform();t.dx();t.dy()

0.0

0.0

>>> t=self.transform();t.dx();t.dy()
0.0
0.0

*To copy to clipboard, switch view to plain text mode *

now translate it to the origin in scene coords:

>>> self.translate(-10,-10)

>>> t=self.transform();t.dx();t.dy()

-10.0

-10.0

>>> self.scenePos()

>>> self.pos()

>>> self.translate(-10,-10)
>>> t=self.transform();t.dx();t.dy()
-10.0
-10.0
>>> self.scenePos()
PyQt4.QtCore.QPointF(0.0, 0.0)
>>> self.pos()
PyQt4.QtCore.QPointF(10.0, 10.0)

*To copy to clipboard, switch view to plain text mode *

you'll notice that the translation and pos coordinate systems are working against each other to have no net effect in the scene coordinates

Now we can move it back with moveBy() which affects the pos() coordinate system not the translation coordinate system:

>>> self.moveBy(10,10)

>>> self.scenePos()

>>> self.pos()

>>> t=self.transform();t.dx();t.dy()

-10.0

-10.0

>>> self.moveBy(10,10)
>>> self.scenePos()
PyQt4.QtCore.QPointF(10.0, 10.0)
>>> self.pos()
PyQt4.QtCore.QPointF(20.0, 20.0)
>>> t=self.transform();t.dx();t.dy()
-10.0
-10.0

*To copy to clipboard, switch view to plain text mode *

I guess my question boils down to the following: since the affine transform coordinate system is much nicer and richer than the separate movement coordinate system, is it OK to base my code just on the former and always have the pos() at (0,0) or will this bite me later with things like boundingRect() shape() etc ?

## Bookmarks