I've played recently with the OpenGL Core Profile and QGLWidget to see if I can render a scene with only core profile functions and shaders. Everything worked well until I decided to add an FPS counter using overlaid text drawn with the QPainter.
In short - it is not possible to use QPainter with the Core Profile. To create such overlays the QGLWidget context should work in Compatibility Mode otherwise application crashes. Additionally all core objects including VBO's shall be properly unbinded in each paint before calling QPainter functions. It really took time for me to understand why my application crashes.
I've uploaded my QT application to the github. It's an example of how to use QGLWidget with shaders and QPainter to lay something over a scene rendered using OpenGL.
To get the code:
git clone https://github.com/flux242/qtzpk.git
To compile and start it QT Creator can be used. Open project file with the QT Creator and press Ctrl-R. At least QT 5.0 is required.