Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PaintEvent being called over and over again
Forum Updated to NodeBB v4.3 + New Features

PaintEvent being called over and over again

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 943 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paludan
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • P Paludan

      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

      P Offline
      P Offline
      Paludan
      wrote on last edited by
      #2

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

      raven-worxR 1 Reply Last reply
      0
      • P Paludan

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

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        @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.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved