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. createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent
Forum Updated to NodeBB v4.3 + New Features

createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 1.1k 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.
  • MasterBLBM Offline
    MasterBLBM Offline
    MasterBLB
    wrote on last edited by
    #1

    Hello mates

    I've encountered such issue - when I add QOpenGLWindow as a central widget of QMainWindow using createWindowContainer() the widget returned from the function covers other child widgets of QMainWindow. QDialog is drawn over the OpenGL area, but sadly not in full screen mode.
    Here is my code:

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
        glWindow = new OpenGLWindow;//inherits QOpenGLWindow
        auto w = createWindowContainer(glWindow);//, this, Qt::WindowStaysOnBottomHint);
        setCentralWidget(w);
    
        toolsAreaDialog = new ToolsAreaDialog(w);//(this);
        toolsAreaDialog->show();
    }
    

    and initialization of OpenGLWindow (I have no experience with OpenGL, might be smth wrong there)

    OpenGLWindow::OpenGLWindow(QWindow *parent)
    : QOpenGLWindow(QOpenGLWindow::NoPartialUpdate, parent)
    {
        QSurfaceFormat format;
        format.setProfile(QSurfaceFormat::CompatibilityProfile);
        format.setVersion(2, 1);
        setFormat(format);
    
        context = new QOpenGLContext;
        context->setFormat(format);
        context->create();
        context->makeCurrent(this);
    }
    

    Any hints how I can paint other widgets above open gl area?

    1 Reply Last reply
    0
    • MasterBLBM Offline
      MasterBLBM Offline
      MasterBLB
      wrote on last edited by
      #13

      You're mistaken mate.

      Nvm anyway, I've managed to solve the issue on my own.

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Why do you use createWindowContainer() in the first place? QOpenGLWindow is already a QWidget.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        jsulmJ 1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          Why do you use createWindowContainer() in the first place? QOpenGLWindow is already a QWidget.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #3

          @Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

          QOpenGLWindow is already a QWidget

          Sure?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Christian EhrlicherC 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

            QOpenGLWindow is already a QWidget

            Sure?

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #4

            @jsulm said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

            Sure?

            Sorry - you're right. Then use QOpenGLWidget instead

            /edit: and why is a child widget simply added to a openglwidget? How should this work out?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            MasterBLBM 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @jsulm said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

              Sure?

              Sorry - you're right. Then use QOpenGLWidget instead

              /edit: and why is a child widget simply added to a openglwidget? How should this work out?

              MasterBLBM Offline
              MasterBLBM Offline
              MasterBLB
              wrote on last edited by MasterBLB
              #5

              @Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

              Sorry - you're right. Then use QOpenGLWidget instead

              /edit: and why is a child widget simply added to a openglwidget? How should this work out?

              Child widget of openglwidget was just a blind try to overcome stacking order issue. About usage of createWindowContainer, it is becase ultimately my application has to support Vulkan rendering too - so after some research I've found it can be done by using the function + QOpenGLWindow or QVulkanWindow.

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                I would guess the whole mess comes from your other widget - you can not add another widget to a QOpenGLWidget/Window. You have to set a normal QWidget as central widget and use a layout to place your widgets there.

                I have no experience with OpenGL

                ultimately my application has to support Vulkan

                I would suggest to stick on one first when you're in such an early learning phase.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                1 Reply Last reply
                0
                • MasterBLBM Offline
                  MasterBLBM Offline
                  MasterBLB
                  wrote on last edited by
                  #7

                  Unless I'm missing something layouts allows to place QWidgets next to each other, right? And what I need is to have openGL/Vulkan window as central widget, and put some other wiget with button directly over it. It works, but only if I show the main window using showMaximized(); when I use showFullScreen() the widget is covered by openGL render surface.

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    You can not place widgets over an QOpenGLWidget directly. It can be done with QGraphicsView iirc.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    MasterBLBM 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      You can not place widgets over an QOpenGLWidget directly. It can be done with QGraphicsView iirc.

                      MasterBLBM Offline
                      MasterBLBM Offline
                      MasterBLB
                      wrote on last edited by
                      #9

                      @Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:

                      You can not place widgets over an QOpenGLWidget directly. It can be done with QGraphicsView iirc.

                      Can't I? Then how you'll explain this?
                      OpenGLTest.PNG ]
                      It's a non-modal QDialog with transparent background, ToolsAreaDialog instance. As you see, it is drawn over central widget which contains embedded QOpenGLWindow.
                      Sadly, this doesn't work in full screen mode of the main window, that's the hint I'm looking for.

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by Christian Ehrlicher
                        #10

                        Is the white area your OpenGL widget/window? If so I already told you how to do it - use a QWidget as centralWidget, add a layout to it and place your widgets there. You can even design it in the designer.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0
                        • MasterBLBM Offline
                          MasterBLBM Offline
                          MasterBLB
                          wrote on last edited by
                          #11

                          No. OpenGL area is the yellow one, white rectangle is smth painted in OpenGL just to have some simple scene. The code of it:

                          void OpenGLWindow::initializeGL()
                          {
                              glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
                              glClear(GL_COLOR_BUFFER_BIT);
                          }
                          
                          void OpenGLWindow::paintGL()
                          {
                              glBegin(GL_QUADS);
                          
                              glVertex2f(-0.5, -0.5);
                              glVertex2f(0.5, -0.5);
                              glVertex2f(0.5, 0.5);
                              glVertex2f(-0.5, 0.5);
                          
                              glEnd();
                          
                              glFlush();
                          }
                          
                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #12

                            You can not simply overlay widgets over an opengl widget - as I wrote earlier it might work with QGraphicsScene since you can create a QGraphicsProxyWidget there.

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            1 Reply Last reply
                            0
                            • MasterBLBM Offline
                              MasterBLBM Offline
                              MasterBLB
                              wrote on last edited by
                              #13

                              You're mistaken mate.

                              Nvm anyway, I've managed to solve the issue on my own.

                              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