[Solved] How to repaint a QGraphicsRectItem embedded inside a QGraphicsPolygonItem
-
Hi Friends,
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 :
@
DiagramItem::DiagramItem(QMenu *contextMenu,
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);
rectItem->setPos(0, 0);
rectItem->setBrush(Qt::gray);
rectItem->show();....
}
@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 ?Please advise.
Appreciate your help.
-
Hi,
you can use "update()":http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#update function.
-
Thank you. It works fine.