QOpenGLWidget fullscreen toggle
<p>I am using Qt 5.6 on Windows (built with the opengl desktop flag, no ANGLE) and I have a widget inheriting QOpenGLWidget as follows:</p>

<pre><code>class SomeWidget: public QOpenGLWidget, protected QOpenGLFunctions
{
    ...
}
</code></pre>

<p>This widget is added in a layout in the main window and has the main window as a parent. The OpenGL stuff displays fine. I want to maximize or make fullscreen that widget and then restore it back to its position / size in the main window. The code looks like that:</p>

<pre><code>onFullscreen()
{
    // remove widget from layout
    // set widget's parent to NULL
    // create a new dialog / layout and add widget to it
    // call dialog-&gt;showFullScreen
}

onRestore()
{
    // set parent to main window
    // insert in main window layout
    // restore original size
    // close dialog
}
</code></pre>

<p>I also added in main():</p>

<pre><code>app.setAttribute(Qt::AA_ShareOpenGLContexts); // onFullscreen() crashes if this line is not present
</code></pre>

<p>I get a black screen when I go to fullscreen and don't see the red clear color. There is no error message. </p>

<p>Interestingly if I replace dialog->showFullScreen() by dialog->showMaximized() the original rendering disappears and I don't see another dialog.</p>

<p>I have the same approach to display another widget fullscreen that does not derive QOpenGLWidget and it works fine.</p>

<p>Any idea on what is going on and how I could achieve to display the QOpenGLWidget in fullscreen and restore it back in its place in the main window ?</p>

<p>Many thanks !</p>