[Qt-interest] polyline gets modified after translation

Srdjan Todorovic todorovic.s at googlemail.com
Wed Jun 17 12:04:21 CEST 2009


Hi,

On 17/06/2009, Sujan Dasmahapatra <sdh at lmglasfiber.com> wrote:
> I  draw a graphicsitems polyline which take the arguments as number of
> points and point list. Now after I do a translation on the graphics
> items do the pointlist gets modified ?

Depends...

> My Geometry class has  members  noOfPoints and QPointF *points;
>
> ////////////////////////////////////////////////////////////////////////
> ////////////////////////////////////
>
> class Geometry:public QGraphicsItem
>
> {
>
>                 Q_Object
>
> public:
>
>                 int noOfPoints;
>
>                 QPointF *points;
>
> };
>
> Now in Geometry class in the paint method  I draw the polyline .
>
> Now I do a translation from on this geometry.
>
> ////////////////////////////////////////////////////////////////////////
> /////////////////
>
> Geometry *geometry;
>
> geometry->translate(dx,dy);

The translate() method does not seem to even use 'points', so I don't
think translate() will change it.

I did not look at the documentation, but from your code, translate()
will be on the QGraphicsItem, which is nothing to do with your
Geometry::points.

But it may be the case that you call some method on your Geometry
object that sets the mapping between the QGraphicsItem and your points
pointer, in which case QGraphicsItem may indeed take ownership and
modify the points...

Srdjan



More information about the Qt-interest-old mailing list