Important: Please read the Qt Code of Conduct -

Qt + OpenGL multithreading

  • Hello,

    I am new to this forum and I have a question.
    I am making a very simple Qt application with OpenGL, with the QOpenGLWidget promoted to a class that I made, let's call it MainWindowOGL that inherits the QOpenGLWidget, I want to run the OpenGL context/rendering in a separate thread from the GUI, I am trying to call std::thread t1(&MainWindowOGL::paintGL, this); from the function initializeGL inside my own class. It compiles just fine but I am still experimenting on how to do this properly and when I run the program i get The program has unexpectedly finished. Even when adding t1.join(); at the end of the initializeGL member function (probably incorrect way of doing it) I get the same issue. My goal is to create a thread where all the OpenGL will run inside a while loop for the life cycle of the application.
    I am using the latest version of Qt and I created the application in designer mode, which means I haven't touched the main.cpp file.
    I am running Ubuntu 14.04 + Nvidia proprietary drivers 361.28.

    Please help!
    Thank you in advanced!

  • Have you tried using Qt3D? It's pretty good for making simple 3d applications with qt.

Log in to reply