It's now recommended to use QWindow for OpenGL drawing. Is it possible to add a widget to this window? If so, how? If not, how should I go about adding widgets to an OpenGL program using Qt5?
An application will typically use QWidget
or QQuickView
for its UI, and not QWindow
directly. QWindow
is more low level than QWidget
. If you want to use QWindow
directly, more work is needed to accomplish the job. You should manually do all drawing related things which is not easy.
However, if you really want a QWindow
/QGuiApplication
instead of QWidget
/QApplication
, you can use QBackingStore which is used by QWidget
, or SceneGraph
which is used by QQuick
in QWindow::exposeEvent()
.
You can see an example of a minimal QWindow
based application using QPainter
here.