0

I use QGraphicsView widget with attached QGraphicsScene in my program. This part works perfect:

    std::vector<unsigned int> nodesCoordsOnScreen;
    for(int i=0; i<nodesCoords.size(); i++)
    {
        unsigned int tempCoord = spaceH+nodesCoords.at(i)*perOneMmH;
        graphVW->scene()->addEllipse(tempCoord, -4, 8, 8, standartPen);
        QGraphicsTextItem* tempText = graphVW->scene()->addText(QString::number(i+1));
        tempText->setPos(tempCoord+8, 0);
        graphVW->scene()->addEllipse(tempCoord+8, 5, 15, 15, standartPen);
        nodesCoordsOnScreen.push_back(tempCoord);
    }

and this has troubles:

    for(int i=0; i<bars->rowCount(); i++)
    {
        unsigned int begin = barsCoords.at(i).first;
        unsigned int end = barsCoords.at(i).second;
        unsigned int begCrd = nodesCoordsOnScreen.at(begin-1);
        unsigned int endCrd = nodesCoordsOnScreen.at(end-1);
        graphVW->scene()->addRect(begCrd+4, (barsAreas.at(i)/2)*perOneMmV, endCrd-begCrd,
                              -(barsAreas.at(i))*perOneMmV, standartPen);
    }

The trouble is strange: when the second part renders - it renders incorrect, but if I move program window or minimize it and return to normal state - it renders correct.

Andrey Belykh
  • 2,578
  • 4
  • 32
  • 46
dimas
  • 13
  • 7

1 Answers1

0

Just need to use QtGraphicsScene::update() after drawings.

dimas
  • 13
  • 7