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 render QOpenGLWidget content from secondary thread?
QtWS25 Last Chance

How to render QOpenGLWidget content from secondary thread?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.3k Views
  • 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.
  • deleted57D Offline
    deleted57D Offline
    deleted57
    wrote on last edited by
    #1

    Hi all

    I have a situation where the main GUI loop is continuosly locked by thirty part code but I would to show an animation keep running without lags. Using QML BusyIndicator control I noted it keep moving also if GUI loop is locked. Checking the sources I knew it have some way to render OpenGL content from different thread. I'm looking for same whay but on C++ side. Is possible to find some example (GL Hypnotizer) but referring to Qt version 4.8. On new 5 version something is changed and these example can not work anymore (GLWidget has been deprecated in favour of QOpenGLWidget that work in a diferent mode). I found some explanation around but that always need the main GUI to notify some lock/unlock state of OpenGL frame buffer and is not what I need. I need a way to render and update the QOpenGLWidget content totally from a secondary thread without any intereaction from main GUI loop.

    Someone can give me help or point to some working example in Qt 5?
    Thank you

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #2

      Hi @Suppaman

      According to qt doc the main thread is always dedicated to GUI

      http://doc.qt.io/qt-5/thread-basics.html#gui-thread-and-worker-thread

      In this link , you can read:

      "All widgets and several related classes, for example QPixmap, don't work in secondary threads. A secondary thread is commonly referred to as a "worker thread" because it is used to offload processing work from the main thread."

      I think that the real problem is that you are locking the GUI thread (which should never happen),

      Maybe you should use worker thread for the computations that are locking your main thread,

      1 Reply Last reply
      0
      • deleted57D Offline
        deleted57D Offline
        deleted57
        wrote on last edited by
        #3

        Hi

        As already wrote QML BusyIndicator can make such operation to keep animation running also if main GUI thread is locked. The info you reported is correct but OpenGL from version 2.0 and above allow to render from a secondary thread that what I want to make is possibile (again only using OpenGL). My problem is I still don't understand how to make it using Qt 5...

        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