Adding QWidget children to QOpenGLWindow
-
I am struggling displaying QWidgets on top of a QOpenGLWindow ( I need to a kind of UI overlay with buttons, texts visible over the ogl content).
Just creating the QWidget as children of the QOpenGLWindow : the QOpenGLWindow content is drawing over the widgets children which are thus not visible.
Using QOpenGLWidget (i.o a QOpenGLWindow) would do the trick : children QWidgets of a QOpenGLWidget are displayed on top of the ogl content but I am unfortunately enforce to use a QOpenGLWindow there (I am using a 3rd party library using a QOpenGLWindow)...I have found a partial solution playing with the window flags (( Qt::Window | Qt::FramelessWindowHint | Qt::CustomizeWindowHint) : this is doing the trick to get the widgets visible. The drawback is that the widgets are not moving with the window anymore (and are still visible when the window is hidden). I guess this drawback is managable but I feel I might be fighting against the design here...
What would you recommand to easily add an UI overlay on top of a QOpenGLWindow ?
If the window flags is the way to go what is the proper combination to have the widget visible but still "acting" as a window child ?I am using Qt6.6.3 and ms windows and android.
Thanks in advance for your help. -
Here is a minimal example showing the issue :
int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; QOpenGLWindow* pOglWnd = new QOpenGLWindow(); QWidget* pWidget = QWidget::createWindowContainer(pOglWnd, &w); w.setCentralWidget(pWidget); QPushButton* pButton = new QPushButton("Overlay", pWidget); pButton->setWindowFlags( Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); pButton->show(); w.show(); return a.exec(); }