[Qt-interest] How to update

Sujan Dasmahapatra sdh at lmglasfiber.com
Thu Jul 2 11:04:48 CEST 2009


Thanks Samuel  I think it's doing fine.Thanks for the help everybody

Kind Regards,
Sujan Dasmahapatra

-----Original Message-----
From: Samuel Rødal [mailto:sroedal at trolltech.com] 
Sent: Thursday, July 02, 2009 2:02 PM
To: Sujan Dasmahapatra
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to update

Sujan Dasmahapatra wrote:
> -----Original Message-----
> From: Samuel Rødal [mailto:sroedal at trolltech.com] 
> Sent: Thursday, July 02, 2009 1:46 PM
> To: Sujan Dasmahapatra
> Cc: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] How to update
> 
> Sujan Dasmahapatra wrote:
>> Dear Friends
>>
>> I have a custom GraphicsItem  Geometry class.
>>
>> *Class Geometry:public  QGraphicsItem*
>>
>> *{*
>>
>> *                Q_OBJECT*
>>
>> *Public:*
>>
>> *                Int  numberOfPoints;*
>>
>> *                QPointF  *points;*
>>
>> *};*
>>
>> * *
>>
>> *Geometry *geometry = new Geometry;*
>>
>> *geometry->setPos(dx+geometry->x(),dy+geometry->y());*
>>
>>  I do a translation on the geometry by setPos() function so the position 
>> of the geometry is changed.How would I update the 'points' with the new  
>> coordinate points??? Please tell me someone.

> I want those coordinates.How could I get those coordinates in point array.I want to save the data points.

In that case you should transform the points by the item's scene 
transform, but don't do it in-place or the points will be transformed twice.

for (int i = 0; i < numberOfPoints; ++i)
	transformedPoints[i] = mapToScene(points[i]);

--
Samuel




More information about the Qt-interest-old mailing list