From 60b3bbdf64f3cdfd6f26d18bd7647a58a415f515 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sun, 8 Sep 2024 17:59:16 +0200 Subject: [PATCH] Gui: Force OpenGL rendering for main window This is big hack for Qt6 to force rendering using OpenGL from the beginning. Since Qt6 OpenGL context is initialized only after creating first QOpenGLWidget which results in window hiding and showing again after some delay. This causes various timing issus as the window is not supposed to do that. --- src/Gui/MainWindow.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 2f0f3352c4..1edeab74f8 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -392,6 +392,14 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) d->whatsthis = false; d->assistant = new Assistant(); +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + // this forces QT to switch to OpenGL mode, this prevents delay and flickering of the window + // after opening project and prevent issues with double initialization of the window + // + // https://stackoverflow.com/questions/76026196/how-to-force-qt-to-use-the-opengl-window-type + new QOpenGLWidget(this); +#endif + // global access instance = this;