[Solved] How to repaint a QGraphicsRectItem embedded inside a QGraphicsPolygonItem
In my project, i have several nodes on a graph. On each node I have to represent the state of the node in the form of 5 colors as a little rectangle attached below it.
I have defined a QGraphicsRectItem inside a QGraphicsPolygonItem as follows :
QGraphicsItem *parent, QGraphicsScene *scene)
: QGraphicsPolygonItem(parent, scene)
rectItem = new QGraphicsRectItem(this, scene);
rectItem->setRect(myPolygon.boundingRect().x(), myPolygon.boundingRect().y() + myPolygon.boundingRect().height() - 30, 200 , 30);
I have subclassed the QGraphicsRectItem actually to write the paint() logic.
On a click of a button, for every node (DiagramItem) on the scene, i want to call a rectItem->updateParameter() function and then repaint the rectItem object. How to call repaint ?
Appreciate your help.
you can use "update()":http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#update function.
Thank you. It works fine.