[Qt-interest] How to update

Samuel Rødal sroedal at trolltech.com
Thu Jul 2 10:16:06 CEST 2009


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.

You don't want to modify the points. As long as you the supplied 
QPainter to draw the points in the graphics item's paint() function, the 
painter's transform will be set up properly to match the item's position 
and transformation, and thus the points will be drawn at the correct 
coordinates.

--
Samuel




More information about the Qt-interest-old mailing list