item translation with QTransform vs change item position
-
Hi all,
I have a big QGraphicsPixmapItem in my QGraphicsView, so I have implemented some scene movement. I mean when I drag mouse - pixmap is moved so I can see different parts of the picute. I can do this two ways:
- by applying QTransform to the QGraphicsItem with translation set in the matrix
- by changing QGraphicsItem x,y position with .setPos() function.
Is there some difference between these two mechanizm especially with performance?
In fact I did this with QTransform, but would like to switch to simply setPos with the item if the performance of the app will not be affected.
Maybe these two mechanizm uses the same method behind the scenes ?Best Regards
Marek -
@FrankiPL
I'd use the simplest solution, i.e.QGraphicsItem::setPos()
.QTransform
resorts to a matrix to perform complex transformations in a single step so using it only for translation seems like overkill (performance shouldn't much suffer though).Is there some difference between these two mechanizm especially with performance?
I don't know for sure.
-
Hi,
Both are different concepts. setPos simply sets the position of the item within the scene. When you call setTransform, you modify the object from where it can be found.
As for performances, you should benchmark both options.