[Qt-interest] Changing the shape of a QGraphicItems

Sujan Dasmahapatra sdh at lmglasfiber.com
Mon Jun 8 11:53:28 CEST 2009


	But this data points are being modiefied from outside Geometry
class so prepareGeometryChange() cannot be called from outside.
I am calling update() but still it's not updating the geometry.

Kind Regards,
Sujan Dasmahapatra
-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Sean Harmer
Sent: Monday, June 08, 2009 3:00 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Changing the shape of a QGraphicItems

Hi,

On Monday 08 Jun 2009 10:07:01 Sujan Dasmahapatra wrote:
> Dear Friends
>
> I think some of u know I am into the development of an aerospace
> software using Qt.I am into the last feature development for my 1st
> version.
>
> I have a QGraphicsItem which is a polyline having  an int nPoints, and
> QPointF points.Now I am developing a gui where I'll select the
geometry
> from the screen and then post the UI.In th UI user will change the
> geometry which will be done from some other code through QProcess.
>
>                 Now after running the code at a button press I'll get
> the new int nPoints and new QPointF points which I am setting with old
> data.
>
> I am trying to do something like this.
>
>
>
>
>
> Geometry *geometry = new Geometry; //Geometry is derived from
> QGraphicsItem which  is displayed on the screen
>
> geometry->npoints = newNumberOfPoints;
>
> for(int i=0;i<newNumberOfPoints;i++)
>
> {
>
>                 Points[i].setX(newx[i]);
>
> Points[i].setY(newy[i]);
>
> }
>
> geometry->update();
>
>
>
> But with this I am not able to see the new geometry.what could be the
> problem can anybody help me plss  ??
You are not adding your Geometry item to the scene either by calling 
QGraphicsScene::addItem() or by passing a parent QGraphicsItem to the
c'tor of 
your class.

A better way might be to simply update the geometry of your existing
item (if 
I read and understood your email correctly). Just be sure to call 
QGraphicsItem::prepareGeomtryChange() to let the framework know about it
so 
that it can reindex the scene as needed.

HTH,

Sean

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list