From d4548751b7b4183ab433df0927d59e3a6650625a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 8 Jun 2020 15:08:45 +0200 Subject: Fix OpenGL mode in examples like composition To avoid an incorrect offset for the native window, call create() after createWindowContainer(). The mysterious -1 for the width and height are removed as well because otherwise the GL window's size is clearly off by one. Fixes: QTBUG-82195 Pick-to: 5.15 Change-Id: I1a9cec62746fc110bfc4cd2e4fa111f621124638 Reviewed-by: Friedemann Kleint Reviewed-by: Allan Sandfeld Jensen --- examples/widgets/painting/shared/arthurwidgets.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/widgets/painting/shared/arthurwidgets.cpp b/examples/widgets/painting/shared/arthurwidgets.cpp index e24130e464..bd8a6d7b62 100644 --- a/examples/widgets/painting/shared/arthurwidgets.cpp +++ b/examples/widgets/painting/shared/arthurwidgets.cpp @@ -129,9 +129,11 @@ void ArthurFrame::createGlWindow() f.setStencilBufferSize(8); m_glWindow->setFormat(f); m_glWindow->setFlags(Qt::WindowTransparentForInput); - m_glWindow->resize(width() - 1, height() - 1); - m_glWindow->create(); + m_glWindow->resize(width(), height()); m_glWidget = QWidget::createWindowContainer(m_glWindow, this); + // create() must be called after createWindowContainer() otherwise + // an incorrect offsetting of the position will occur. + m_glWindow->create(); } #endif @@ -235,7 +237,7 @@ void ArthurFrame::resizeEvent(QResizeEvent *e) { #if QT_CONFIG(opengl) if (m_glWidget) - m_glWidget->setGeometry(0, 0, e->size().width()-1, e->size().height()-1); + m_glWidget->setGeometry(0, 0, e->size().width(), e->size().height()); #endif QWidget::resizeEvent(e); } -- cgit v1.2.3