[Qt-interest] Changing the shape of a QGraphicItems
Sean Harmer
sean.harmer at maps-technology.com
Mon Jun 8 11:30:25 CEST 2009
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
More information about the Qt-interest-old
mailing list