I recently decided to switch from QGLWidget to QOpenGLWidget for a rendering context for my game engine editor. It went smoothly; I set the version (OpenGL 3.3), using default format, and I am using GLEW for most of the OpenGL standard functions. Everything was working perfectly before I switched to the QOpenGLWidget (recommended by a stack exchange post about another small tweak I was making). I checked the rendering context using the QT valid() function, and I made sure the context wasn't lost by verifying they were the same pointer.
My problem is that my VAOs throw INVALID_OPERATION whenever I bind them, and my draw function does the same. It's nothing out of the ordinary, standard triangles and such. And it actually worked hunky dory on the QGLWidget. The funny thing is that it's not all the VAOs; the skybox I have and the basic line drawer does work, it's just the models.
Is there a way to verify VAO integrity if I'm stuck using GLEW? I initialize the same as if I were making the skybox, but I'm open to solutions.
One thing I would check is that you have the Qt::MSWindowsOwnDC flag set when you construct the QOpenGLWidget. You don't need this for the older QGLWidget but I found it must be set for the new QOpenGLWidget. If it is not set then strange things happen (and lots of crashes).
The rendering context is associated with the device context in Win32. The Qt::MSWindowsOwnDC sets the equivalent flag in the Win32 window class that QOpenGLWidget uses. You need this set for any Win32 opengl program you create on Windows as far as I know.
I did a tiny bit of googling and found that it is a window flag, so I set that flag in addition to the other flags that are automatically added. The problem does persist, but I wouldn't be surprised if there is still a setup thing I am missing. Do you have any other ideas?