Add QWidget on top of QOpenGLWindow

1.5k Views Asked by At

I want to add QWidget on top of my QOpenGLWindow. For example:

In qmainwindow.cpp:

QWidget *mywidget = new QWidget(this);
mywidget->hide();

QOpenGLWindow *glwindow = new QOpenGLWindow();
QWidget *container = QWidget::createWindowContainer(glwindow, this);

// ...

ui->tabWidget->addTab(container, "Container");

// then I want mywidget to be at the top of my tabWidget and container.
mywidget->show();

But mywidget is behind the container.

How can I solve this problem?

1

There are 1 best solutions below

0
On

Qt cannot divine what Z order you want if you don't create the widgets in Z order. You need to raise the widget. The whole hiding rigmarole is completely unnecessary anyway. Simply create the widget where you need it.