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() not called after call to update()
Forum Updated to NodeBB v4.3 + New Features

paintEvent() not called after call to update()

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 6 Posters 6.9k Views 2 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.
  • C Offline
    C Offline
    cone
    wrote on last edited by cone
    #1

    I have a small application which displays some video data at 20 fps or lower. There is one thread receiving the video data, which calls update() on the display widget whenever a new frame is available that should be displayed. The display widget then draws this frame in the paintEvent() method.

    On Windows this works quite well but I'm having problems on Linux (I'm running Ubuntu 16.04). On Linux the video is displayed, but occasionally the widget stops updating. I have done some debugging and realized that my thread still calls the update() method, but the paintEvent() method stops being called. The last call to paintEvent() does finish without blocking.

    When I produce some other GUI events by resizing the window or pressing a button on the toolbar, then the widget suddenly continues to receive paintEvents() again until this issue happens again.

    I think this doesn't just affect the paintEvent() but other events as well. I'm also occasionally updating some other widgets which sometimes also stops when this error occurs.

    Any ideas what might be happening here?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      That's most likely due to the way update() prevents multiple fast repaints. call repaint() instead and see if it fixes the problem without much of a loss of performance

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      J 1 Reply Last reply
      4
      • C Offline
        C Offline
        cone
        wrote on last edited by
        #3

        Thanks, that seems to have worked :-)

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wawan
          wrote on last edited by
          #4

          @VRonin thanks, it works well !

          @VRonin said in paintEvent() not called after call to update():

          update() prevents multiple fast repaints

          Where can I find this in documentation ? Didn´t find anything related to multiple update prevention.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi @wawan, it's in the documentation of the repaint method.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1
            • VRoninV VRonin

              That's most likely due to the way update() prevents multiple fast repaints. call repaint() instead and see if it fixes the problem without much of a loss of performance

              J Offline
              J Offline
              jaggusri12
              wrote on last edited by
              #6

              @VRonin Even I call repaint() ,It doesn't call paintEvent() immediately. some how few paintEvent() calls are missing . What I observed is that the paintEvent() called asynchronously.

              Christian EhrlicherC 1 Reply Last reply
              0
              • J jaggusri12

                @VRonin Even I call repaint() ,It doesn't call paintEvent() immediately. some how few paintEvent() calls are missing . What I observed is that the paintEvent() called asynchronously.

                Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @jaggusri12 said in paintEvent() not called after call to update():

                What I observed is that the paintEvent() called asynchronously.

                Which is exactly how it should work...

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                J 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  @jaggusri12 said in paintEvent() not called after call to update():

                  What I observed is that the paintEvent() called asynchronously.

                  Which is exactly how it should work...

                  J Offline
                  J Offline
                  jaggusri12
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher As per Qt documentation Repaint , Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. As per my understanding, Repaint should invoke the paintEvent() immediately, but It observed similar behavior both update() and repaint().

                  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