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. How to redraw certain area of window constantly when Main thread is busy.
Forum Updated to NodeBB v4.3 + New Features

How to redraw certain area of window constantly when Main thread is busy.

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 5 Posters 1.0k 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.
  • K Offline
    K Offline
    kosuke
    wrote on last edited by
    #1

    Hi all,

    We’re developing a QWidget-base application on Linux.
    The window has certain area which need to be redrawn constantly, ideally 60fps.
    But it stops when the Main thread is busy, for example when app needs to redraw all areas following by certain event.

    Firstly we tried to use QtQuick, but the render thread is not completely independent from the Main thread.
    So the area still stopped when Main thread was busy.

    Secondly we’re trying the direct drawing using Wayland + EGL + OpenGL.
    We created an independent thread from Application and draw that area with Wayland + EGL + OpenGL.
    In this case, the area was drawn constantly even when the Main thread was busy.
    But it still has an issue that once the Main thread is activated by mouse click or touch, the area is hidden. We’ve not found a way to make the area always on top.

    If anyone know a solution, please let us know.
    We also welcome other ways to realize what we want.

    raven-worxR JoeCFDJ 2 Replies Last reply
    0
    • K kosuke

      Hi all,

      We’re developing a QWidget-base application on Linux.
      The window has certain area which need to be redrawn constantly, ideally 60fps.
      But it stops when the Main thread is busy, for example when app needs to redraw all areas following by certain event.

      Firstly we tried to use QtQuick, but the render thread is not completely independent from the Main thread.
      So the area still stopped when Main thread was busy.

      Secondly we’re trying the direct drawing using Wayland + EGL + OpenGL.
      We created an independent thread from Application and draw that area with Wayland + EGL + OpenGL.
      In this case, the area was drawn constantly even when the Main thread was busy.
      But it still has an issue that once the Main thread is activated by mouse click or touch, the area is hidden. We’ve not found a way to make the area always on top.

      If anyone know a solution, please let us know.
      We also welcome other ways to realize what we want.

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

      @kosuke said in How to redraw certain area of window constantly when Main thread is busy.:

      But it stops when the Main thread is busy, for example when app needs to redraw all areas following by certain event

      it is the main thread, because drawing is happening there and only there.
      So there is no way around it, other to optimize your load on the main thread.

      --- 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
      1
      • N Offline
        N Offline
        nickmillers
        Banned
        wrote on last edited by nickmillers
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • K kosuke

          Hi all,

          We’re developing a QWidget-base application on Linux.
          The window has certain area which need to be redrawn constantly, ideally 60fps.
          But it stops when the Main thread is busy, for example when app needs to redraw all areas following by certain event.

          Firstly we tried to use QtQuick, but the render thread is not completely independent from the Main thread.
          So the area still stopped when Main thread was busy.

          Secondly we’re trying the direct drawing using Wayland + EGL + OpenGL.
          We created an independent thread from Application and draw that area with Wayland + EGL + OpenGL.
          In this case, the area was drawn constantly even when the Main thread was busy.
          But it still has an issue that once the Main thread is activated by mouse click or touch, the area is hidden. We’ve not found a way to make the area always on top.

          If anyone know a solution, please let us know.
          We also welcome other ways to realize what we want.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @kosuke try to add a mutex lock in the paint event of that area. Only one thread is allowed to draw it.

          JonBJ 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @kosuke try to add a mutex lock in the paint event of that area. Only one thread is allowed to draw it.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @JoeCFD
            Are you suggesting that it is OK for different threads to do paint events provided they use a mutex?

            JoeCFDJ 1 Reply Last reply
            0
            • JonBJ JonB

              @JoeCFD
              Are you suggesting that it is OK for different threads to do paint events provided they use a mutex?

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by
              #6

              @JonB It is multi-threading. The same area has to be painted one after another.

              JonBJ 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @JonB It is multi-threading. The same area has to be painted one after another.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @JoeCFD
                Let me start by saying I have not done anything in this area, so your knowledge may be greater than mine.

                I understood that in Qt all UI operations must be performed in one UI thread, and no UI ops directly from other threads. I did not think this was just a mutex issue. And I kind of thought @raven-worx was implying the same. That's all I was thinking of.

                JoeCFDJ 1 Reply Last reply
                0
                • JonBJ JonB

                  @JoeCFD
                  Let me start by saying I have not done anything in this area, so your knowledge may be greater than mine.

                  I understood that in Qt all UI operations must be performed in one UI thread, and no UI ops directly from other threads. I did not think this was just a mutex issue. And I kind of thought @raven-worx was implying the same. That's all I was thinking of.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by JoeCFD
                    #9

                    Maybe simply override paintEvent(QPaintEvent event) of this area and call your draw function from paintEvent(QPaintEvent event) of this area. This draw func is called in your thread. Add mutex lock into it. Do not repaint the parent of this draw area. This means that this area is updated only from your func draw().

                    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