Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.6.2
-
None
-
This is on an Apple M1 MacBook Pro with MacOS X 10.14, and Qt 6.6.2.
Description
I have run into a bug which makes it impossible to show both an OpenGL widget as well as a WebEngine widget in the same MDI area. The code to replicate this is as follows:
#include <iostream> #include <QToolBar> #include <QApplication> #include <QMainWindow> #include <QMdiArea> #include <QOpenGLWidget> #include <QMdiSubWindow> #include <QWebEnginePage> #include <QWebEngineView> class PlainGLWidget : public QOpenGLWidget { protected: virtual void paintGL(); }; void PlainGLWidget::paintGL() { int i; float x1, y1, x2, y2; glClearColor(1.0, 1.0, 1.0, 0.5); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLineWidth(30.); glColor4f(0.2, 0.3, 0.1, 0.3); for(i=0;i<=100;i++) { glBegin(GL_LINE_STRIP); x1 = -float(rand() % 10); y1 = -float(rand() % 10); x2 = float(rand() % 10); y2 = float(rand() % 10); glVertex2f(x1, y1); glVertex2f(x2, y2); glEnd(); } } int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create a QMainWindow with an MDI area and a toolbar QMainWindow *window = new QMainWindow; QMdiArea *mdi = new QMdiArea; window->setCentralWidget(mdi); // Show window now - in the real application I am writing, the MDI sub-windows // get created on-the-fly and so the MDI area gets shown first. window->show(); window->raise(); // Create OpenGL widget PlainGLWidget *glwidget = new PlainGLWidget; // Wrap the OpenGL widget in MDI sub-window and add to MDI area QMdiSubWindow *sub1 = new QMdiSubWindow; sub1->setWidget(glwidget); mdi->addSubWindow(sub1); sub1->resize(400,400); sub1->show(); // Create WebEngine widget QWebEnginePage *page = new QWebEnginePage; QWebEngineView *web = new QWebEngineView; web->setPage(page); web ->setUrl(QUrl("https://www.qt.io")); // Wrap the WebEngine widget in MDI sub-window and add to MDI area QMdiSubWindow *sub2 = new QMdiSubWindow; sub2->setWidget(web); mdi->addSubWindow(sub2); sub2->resize(400,400); sub2->move(400,0); sub2->show(); return app.exec(); }
With this code, the application looks like the 'both.png' attachment. I have also included screenshots showing what happens if I only add one of the widgets to the MDI area. The output in 'both.png' is wrong, and the OpenGL widget appears to show an image of the whole window inside itself.