[Solved] Dragging a QGraphicsItem over another is distorting the other QGraphicsItem's color

  • Hi.
    I have implemented a QGraphicsRectItem inside a QGraphicsPolygonItem. The QGraphicsRectItem item displays a color.
    When i slide one QGraphicsPolygonItem over the other, the color is getting distorted and becoming white(default color of it's parent i.e. QGraphicsPolygonItem)

    I have implemented following -
    void DiagramItem::paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget )

    if (option->state & QStyle::State_Selected)


    where DiagramItem is a subclass of QGraphicsPolygonItem.
    This tremendously increases my CPU utilization....

    What is a probable solution to this problem ?


  • I don't really see how your code snippet relates to your problem. Maybe you could post a more complete code sample?

    I find it interesting that you call scene()->update(); within paint - couldn't that cause the CPU utilization?

  • I recognized my error. I created a public function which mocks functionality of paint() in QGraphicsRectItem and then call the dummy paint() from QGraphicsPolygonItem.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.