Search code examples
qtqgraphicssceneqgraphicsitem

QGraphicsEffect doesn t refresh correctly


Actually i have a QPolygonF who can only move horizontally and when it does, it draws an shadow effect from its initial point to his current. That works great but when i m moving the polygon too fast i got residual effects who doesnt clear correctly or some blank point appears in my shadows.

here is my code s effect

void    ShadowEffect::draw(QPainter *painter)
{
    QBrush b(QColor(0,0,0,128)); // adjust color and alpha to taste
    painter->setBrush(b);
    painter->setPen(QPen(QColor(0,0,0,128)));
    painter->drawRect(0, 0, *dist, 10+slider->size().height()*1.5);
    drawSource(painter);
}

What it looks like


Solution

  • Resolved. The scene wasn t updated correctly so i just put a trigger in my class to call it everytime i moved the polygone

        connect(myPolygon, &MyPolygon::valueChanged, [scene](){scene->update();});