createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent
-
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?
-
Why do you use createWindowContainer() in the first place? QOpenGLWindow is already a QWidget.
-
Why do you use createWindowContainer() in the first place? QOpenGLWindow is already a QWidget.
@Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:
QOpenGLWindow is already a QWidget
Sure?
-
@Christian-Ehrlicher said in createWindowContainer() for QOpenGLWindow - returned widget covers other widgets of the same parent:
QOpenGLWindow is already a QWidget
Sure?
@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?
-
@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?
@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.
-
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.
-
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.
-
You can not place widgets over an QOpenGLWidget directly. It can be done with QGraphicsView iirc.
-
You can not place widgets over an QOpenGLWidget directly. It can be done with QGraphicsView iirc.
@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?
]
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. -
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.
-
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(); }
-
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.