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.
This commit is contained in:
Kacper Donat
2024-09-08 17:59:16 +02:00
committed by wwmayer
parent 265909da4a
commit 60b3bbdf64

View File

@@ -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;