Qt crushes when setting QGLContext current in separate thread



  • Hi All.I am creating QGLWidget.Inside that widget I start a thread function inside which I create a new OpenGL context.Once I call makeCurrent() the app crushes.

    Here is my code:

    @
    
       bool GLThreadedWidgetBOOST::initialize(){
          
        //create context from inside thread
        QGLFormat format;
        format.setProfile(QGLFormat::CompatibilityProfile);
        format.setVersion(4,3);
        format.setDoubleBuffer(true);
        QGLContext *glContext=new QGLContext(format, this);
        if(!glContext->create()){
            qDebug()<< "Error creating context";
        }
        setContext(glContext);
        //make sure new context is current
    
        makeCurrent();
    
      }
    

    @

    What am I doing wrong?



  • Ok,solved,the problem was I didn't call the super class constructor in the initialization list.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.