在QOpenGLWindow之上添加QWidget

Add QWidget on top of QOpenGLWindow

本文关键字:添加 QWidget QOpenGLWindow      更新时间:2023-10-16

我想在我的QOpenGLWindow上添加QWidget。例如:

在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();

但是mywidget容器后面。

我该如何解决这个问题?

如果您不按Z顺序创建小部件,Qt就无法判断您想要的Z顺序。您需要对小部件进行raise。无论如何,整个隐藏的繁文缛节是完全不必要的。