Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] How to repaint a QGraphicsRectItem embedded inside a QGraphicsPolygonItem

[Solved] How to repaint a QGraphicsRectItem embedded inside a QGraphicsPolygonItem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    amban
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MaQzma
      wrote on last edited by
      #2

      Hi,

      you can use "update()":http://qt-project.org/doc/qt-4.8/qgraphicsitem.html#update function.

      Mario.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        amban
        wrote on last edited by
        #3

        Thank you. It works fine.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved