Important: Please read the Qt Code of Conduct -

paint method of QGraphicItems & QGraphicsItemGroup do not fire after some while or some minimize/maximize of window

  • Hi everyone,
    I have been developing a graphical application.
    I have some graphical object inheriting from QGraphicsItems. I have added all of them into a QGraphicsItemGroup object and then add the QGraphicsItemGroup object to a QGraphicScene object. The QGraphicScene is created from a QGraphicView.

    The problem is that after some minimizing/maximizing the main window the drawing process will be stopped though a function trigges some methods inside the QGraphicsItemGroup object. And also, the QGraphicsItemGroup object call some method of the QGraphicsItems objects. Inside ever mehtod of QGraphicsItems/QGraphicsItemGroup the update function is called. But the paint mathod does not fire.

    Is there anyone who has some ideas how I can solve it or figure the problem out.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Which version of Qt ?
    On which OS ?
    Are you using any custom class with custom painting.

  • Hi there,
    Thanks for the reply.

    I am using Qt V5.12.1 with MinGW 7.3.0 64-bit on Windows 10.

    In fact, I have developed some classes inheriting from QGraphicItems or QgraphicItemGroup.

    For instance :
    MyFuzzyItem class inherits from QGraphicItem and then it will be added as Item to another class which inherits from QGraphicItemGroup ( Let's call it FuzzyComponent). And finally, FuzzyComponent will be added to the scene.
    Also, I override paint methods in each class to draw something.

    Hints :
    1- The update function of the scene works properly meaning that it can be called to redraw. But update methods of the inside items of the scene do not work. ( It happens after a while or doing some minimize/maximize of the main window. So, it is required to restart the application.)
    Also, I found out that other functions which I call from outside are working properly. I use them for changing some data which must lead to change the graphical items. I call the update method of the graphical object after changing the data. But it does not work.

    2- While the update methods do not work, the other events like the mouse Hover Enter/Leave work.

    3- While the scene does not update from inside, on every main-window maximizing the scene is redrawn and it reacts to all user action done at once( only one time).

  • Lifetime Qt Champion

    Can you update your Qt version ? If you can't leave the 5.12 series, try the latest patch release.

  • Sure, I'll do it and check the problem.

  • It seems solved by updating the Qt though I checked my code on Ubuntu. It has not happened. So, I think the bug source might be MinGW. I hope I won't see it again.

  • Lifetime Qt Champion

    I'd rather go with a platform issue rather than a compiler one. In any case, glad it's fixed :-)

    Since it's working now, please mark the thread as solved so other forum users may know a solution has been found :-)

  • @SGaist Thanks for your help.

Log in to reply