-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.0
-
None
-
macOS Mojave version 10.14
I am having an issue where the QOpenGLWidget does not appear to work properly unless I manually resize the widget. I noticed if my QMainApplicationWindow uses other widgets beside a QOpenGLWidget it works fine. In the code sample below, it demonstrates what our application does where:
- We create the QApplication
- Display a simple modal dialog
- After the user clicks Accept, we show a QMainWindow containing the QOpenGLWidget
- Observe the QMainApplicationWindow appears blank unless you resize it.
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setOrganizationName("SecretLevel");
app.setOrganizationDomain("secret.com");
app.setApplicationName(APP_NAME);
app.setApplicationVersion(APP_VERSION);
QDialog *dlg = new QDialog(nullptr, Qt::Dialog);
QGridLayout *grid = new QGridLayout();
dlg->setLayout(grid);
//--- Ok/Cancel buttons ---
QHBoxLayout *pwLayout = new QHBoxLayout();
QPushButton *okBtn = new QPushButton("Login");
dlg->connect(okBtn, SIGNAL(clicked()),
dlg, SLOT(accept()));
QPushButton *cancelBtn = new QPushButton("Cancel");
dlg->connect(cancelBtn, SIGNAL(clicked()),
dlg, SLOT(reject()));
grid->addWidget(okBtn);
grid->addWidget(cancelBtn);
dlg->setAttribute(Qt::WA_DeleteOnClose);
if(dlg->exec() == QDialog::Accepted) {
QMainWindow *testWindow = new QMainWindow();
testWindow->resize(600, 500);
testWindow->show();
app.exec();
}
}
Workaround: Install a QTimer on the parent QMainWindow that's set to a certain interval. After the window is exposed and after the child QOpenGLWidget isValid() returns true, resize the widget to a different size (note: it cannot be the same size, nor does repaint(), update(), or update(0, 0, width, height) work)
QWindow *window = windowHandle();
if(window && window->isExposed() && _glWidget->isValid()) {
resize(801,601);
_timer.stop();
}