PaintEvent being called over and over again



  • Hello,
    I'm very new to Qt and may be misunderstanding how drawing works using this framework. But it seems that the only way I can draw something on a form is by putting the drawing code within the PaintEvent function. What is supposed to be drawn are n lines between x points. It is intentional that the way it is drawing is this way. But for some reason when it's done drawing it begins over again, as if the PaintEvent is being called again and again. You can see the source code here for the PaintEvent:
    https://hastebin.com/oduzuveqec.cpp

    Any ideas on why this is happening and how I can prevent it? When it's done drawing all lines between every point then it is should stop and display the drawed lines to the user.

    Best regards,
    Paludan



  • @Paludan
    It seems this only happens when I attempt to draw a line from a point that is "above" the new next point.


  • Moderators

    @Paludan
    this is fine.
    The only thing you should care about is implementing the paintEvent() handler and when painting relevant data changes you need to call update() (on the widget).

    The rest is handled by Qt. So when you are not calling update() or repaint() unnecessarily the amount of paint events is most probably fine.


Log in to reply
 

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