When using a window manager such as Rectangle, the window will blank to grey when resized by the manager if it contains a QOpenGLWidget. This doesn't happen if it only contains regular widget.
This can be demonstrated with this simple program:
(sorry, I'm unable to provide a C++ version of the same)
Here is a recording of the behaviour:
Note that for a resizeGL()/paintGL() implementation, resizeGL() is called when the window manager resizes the window, but paintGL() is not.
If MyWidget() is replaced by some other widget (e.g. a button), the behaviour is as expected.