PDA

View Full Version : Scale individual QGraphicsItem's size and position



klep
17th December 2011, 06:42
I have one question for all, regarding QGraphicsPolygonItem scaling size and position.

On my scene located many different QGraphicsItem's and QGraphicsWidget (editor for them) also.
When user want to edit QGraphicsItem's he must select them and press Edit button. QGraphicsWidget create copy of them and show it on its surface.
Optional, user can zoom in/out those shapes which located on QGraphicsWidget only (not for all scene).

Every QGraphicsItems is selectable and movable and consist QGraphicsPolygonItem with data:

Example:


QPolygonF p1;
p1 << QPointF(-4, 32) << QPointF(-4, -32) << QPointF(4, -32) << QPointF(4, 32);


So , User can select and move items and then say - Zoom In.
When I try to scale it ( setScale(2) ) size of item scaled but position not.
How to scale it's position too ?

I have read a lot of documentation about QTransform and found QTransform.translate could help me.
But how to calculate QTransform matrix for current item position ?

Thank you for any help

p.s
Qt 4.6.3, g++ 4.4.3, Linux

Lykurg
17th December 2011, 09:29
Hi, see QGraphicsItem::transformOriginPoint().