Important: Please read the Qt Code of Conduct -

QOpenGLWidget force initialisation

  • Hi there,
    I am trying to setup 2 QOpenGLWidget as tabs in a QTabWidget.
    I need to perform initialisation in the GL widgets requiring the context at some point (shaders init).
    The problem is that the OpenGLWidget that is located in the visible tab is well initialised, but the other one not (certainly because it is not visible).
    What is the correct way to force the initialisation of this second GLWidget programmatically ?

  • You'll need to change the context to the second GL widgets before using it.
    As each time you render or do anything with OpenGL setup/parameters that you have the right context selected first for each widget.