I am migrating some code from FLTK to QT5 and I can’t seem to get a widget in the graphical designed that corresponds to an OpenGL context? Does such a widget exist?
I built QT from the official sources, targeting VS2012x64 with the OpenGL option and have tried to add QT += opengl to my project.pro file.
Qt has the QGLWidget, but you should not use that directly in the Designer. Instead you should place a layout where you want the OpenGL widget to appear. Then you subclass QGLWidget, as you must overwrite the
paintGLfunction anyway to draw something. Then after thesetupUI()call you instanciate your custom GL widget and add it to the layout you placed in the designer withlayoutinstance->addWidget(…)update due to comment
mainwindow.ui
myglwidget.hh
mainwindow.hh
The key is, that you use just a layout. An ordinary, regular layout in the UI, to which you add your derived OpenGL widget. No morphs, no promotions in the ui!