From 08a901a0d027610fd1046352700728d9353e756f Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 21 Mar 2017 13:09:56 +0100 Subject: [PATCH] Qt5OpenGL: fix to make the 3d viewer fit into the mdi area after re-docking it --- src/Gui/View3DInventor.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index ae5521c5cb..9e1f84a5a6 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -54,6 +54,11 @@ # include #endif # include +#include + +#if defined(HAVE_QT5_OPENGL) +# include +#endif #include #include @@ -982,6 +987,21 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode) ViewMode oldmode = MDIView::currentViewMode(); if (oldmode == newmode) return; + +#if defined(HAVE_QT5_OPENGL) + if (newmode == Child) { + // Fix in two steps: + // The mdi view got a QWindow when it became a top-level widget and when resetting it to a child widget + // the QWindow must be deleted because it has an impact on resize events and may break the layout of + // mdi view inside the QMdiSubWindow. + // In the second step below the layout must be invalidated after it's again a child widget to make sure + // the mdi view fits into the QMdiSubWindow. + QWindow* winHandle = this->windowHandle(); + if (winHandle) + winHandle->destroy(); + } +#endif + MDIView::setCurrentViewMode(newmode); // This widget becomes the focus proxy of the embedded GL widget if we leave @@ -1009,6 +1029,13 @@ void View3DInventor::setCurrentViewMode(ViewMode newmode) QList acts = this->actions(); for (QList::Iterator it = acts.begin(); it != acts.end(); ++it) this->removeAction(*it); + +#if defined(HAVE_QT5_OPENGL) + // Step two + QMdiSubWindow* mdi = qobject_cast(parentWidget()); + if (mdi && mdi->layout()) + mdi->layout()->invalidate(); +#endif } }