diff options
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 22ea852d99..2abddd8941 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -587,7 +587,8 @@ void QOpenGLWidgetPrivate::initialize() // Get our toplevel's context with which we will share in order to make the // texture usable by the underlying window's backingstore. - QOpenGLContext *shareContext = get(q->window())->shareContext(); + QWidget *tlw = q->window(); + QOpenGLContext *shareContext = get(tlw)->shareContext(); if (!shareContext) { qWarning("QOpenGLWidget: Cannot be used without a context shared with the toplevel."); return; @@ -601,6 +602,19 @@ void QOpenGLWidgetPrivate::initialize() return; } + // Propagate settings that make sense only for the tlw. + QSurfaceFormat tlwFormat = tlw->windowHandle()->format(); + if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) { + // Most platforms will pick up the changed swap interval on the next + // makeCurrent or swapBuffers. + tlwFormat.setSwapInterval(requestedFormat.swapInterval()); + tlw->windowHandle()->setFormat(tlwFormat); + } + if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) { + tlwFormat.setSwapBehavior(requestedFormat.swapBehavior()); + tlw->windowHandle()->setFormat(tlwFormat); + } + // The top-level window's surface is not good enough since it causes way too // much trouble with regards to the QSurfaceFormat for example. So just like // in QQuickWidget, use a dedicated QOffscreenSurface. |