Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Adding QWidget children to QOpenGLWindow
Forum Updated to NodeBB v4.3 + New Features

Adding QWidget children to QOpenGLWindow

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 336 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CharbyC Offline
    CharbyC Offline
    Charby
    wrote on last edited by Charby
    #1

    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.

    1 Reply Last reply
    0
    • CharbyC Offline
      CharbyC Offline
      Charby
      wrote on last edited by Charby
      #2

      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();
      }
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved