How to workaround the "pure virtual method called - QWidget::repaint: Recursive repaint detected" issue?

  • Hey,
    In my code, I delete a QGraphicsItem derived object.

                delete d;

    I used it in a QGraphicsScene, but as you can see, I removed it from the scene and the array the object is stored in (dataExecOuputs).
    This works without compiler errors but at runtime, the program crashes after I deleted the object with:

    pure virtual method called
    QWidget::repaint: Recursive repaint detected

    This is a known issue, but I can't find a working solution for me.
    Do you have any ideas how I can avoid that crash?
    I have to remove this object when I call a update() function and the object I want to delete is not anymore in another array (so it is only in the dataExecOuputs array anymore and nowhere else).
    Thanks for answers!

  • Lifetime Qt Champion


    What makes it mandatory for you to do that in the update method ?

    Because that's what is triggering the recursive repaint: you are running update in which you trigger an update again etc.

  • @SGaist
    Where do I do this?
    With update I mean a custom update() method by me, not the actual update of the class itself. I call my custom update updateInputs() when I change something in a specific lineEdit in a formular. That's the weird thing with the bug, that I even do not call update manually. When comment out the delete line, everything works, so the delete command causes this error, but this is a known issue since qt 5 I guess, I am not the first one with these weird recursive repaint outputs. I just would like to know how I can get around it :/

  • Lifetime Qt Champion

    That's the kind of detail that is pretty important.

    If you can provide a minimal compilable example that shows that behaviour, that would avoid having to guess what is happening while guessing how your application is currently running.

Log in to reply

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