I use the GLWidget class from the hellogl sample.

In initializeGL(), I want to access the current QGLContext and call makeCurrent(), doneCurrent() to make it available to other rendering threads and make it unavailable to current thread.

To do this, I call QGLContext::currentContext(). But the return type is a const* pointer, hence I can't call QGLContext::doneCurrent().

If I instead create my own context via
QGLContext* p = new QGLContext( QGLFormat::defaultFormat() );
bool result = p->create();

result is always 0. Same with other ways to construct QGLFormat.

Thanks